Actually I am trying to get all unchecked checkbox value but where title = 1 condition..please help.my jquery code is.
var uncheckedValues = $('input[type="checkbox"][name="ing[]"][title= "1"]:not(:checked)').map(function() { return this.value; }).get();
and my checkbox code is
<input class="badgebox" type="checkbox" onClick="addprice(<?php echo $total; ?>,<?php echo $addingri->id; ?>,'<?php echo $pprod_material->name; ?>')" id="<?php echo $addingri->id; ?>" value="<?php echo $pprod_material->id; ?>*<?php echo $addingri->price; ?>*<?php echo $addingri->name; ?>" name="ing[]" <?php if($pprod_material->id == 1) { echo "checked";} ?> title="<?php echo $pprod_material->id; ?>" >
Use $("input[type='checkbox'][name='ing[]'][title= '1']:not(:checked)") selector to get all the unchecked checkbox having title="1".
Please check below working snippet.
$(document).ready(function(){
//On page load
uncheckedChk();
//on checkbox change
$("input[type='checkbox'][name='ing[]'][title= '1']").on("change",function(){
uncheckedChk();
});
});
//Function to identify all the unchecked checkbox with title=1
function uncheckedChk(){
var not_checked = []
$("input[type='checkbox'][name='ing[]'][title= '1']:not(:checked)").each(function (){
not_checked.push($(this).val());
});
console.log(not_checked);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox" name="ing[]" value="check-1" title="1" checked><br/>
<input type="checkbox" name="ing[]" value="check-2" title="1" checked><br/>
<input type="checkbox" name="ing[]" value="check-2" title="1" ><br/>
<input type="checkbox" name="ing[]" value="check-3" title="1"><br/>
<input type="checkbox" name="ing[]" value="check-4" title="2" ><br/>
<input type="checkbox" name="ing[]" value="check-5" title="1" ><br/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With