xxxxxxxxxx
$("input[type='checkbox']").val();
$('#check_id').val();
xxxxxxxxxx
$('#checkbox_id:checked').val();
//if checkbox is selected than gets its value
xxxxxxxxxx
console.log($('input[name="locationthemes"]:checked').serialize());
//or
$('input[name="locationthemes"]:checked').each(function() {
console.log(this.value);
});
xxxxxxxxxx
$('input[name="checkboxGroup"]:checked'); // returns checked input objects
jquery get selected checkbox values
xxxxxxxxxx
var selectedLanguage = new Array();
$('input[name="language"]:checked').each(function() {
selectedLanguage.push(this.value);
});
xxxxxxxxxx
$.each(arrayValues, function(i, val){
$("input[value='" + val + "']").prop('checked', true);
});
xxxxxxxxxx
<input type="checkbox" name="locationthemes" id="checkbox-1" value="2" class="custom" />
<label for="checkbox-1">Castle</label>
<input type="checkbox" name="locationthemes" id="checkbox-2" value="3" class="custom" />
<label for="checkbox-2">Barn</label>
<input type="checkbox" name="locationthemes" id="checkbox-3" value="5" class="custom" />
<label for="checkbox-3">Restaurant</label>
<input type="checkbox" name="locationthemes" id="checkbox-4" value="8" class="custom" />
<label for="checkbox-4">Bar</label>
xxxxxxxxxx
var grenval = $('.green').val();
$('.showCheckedValue').text(redval+'&'+grenval );