I have input checkbox namely select all. I added the checkbox from jquery end. if user click on select all rest of the option will be checked. but I'm getting error when click on select all. here I'm attaching the code.
$('#multiple_msisdn').append(
'<label class="exp" style="margin-bottom: 5px; display: inline-block;">
<input type="checkbox" class="exp" onclick="$(input[name=msisdn\\[\\]])
.attr(checked, this.checked)">-- Select All -- </label>');
error: uncaught syntaxError.
error generated here
$(input[name=msisdn\[\]]).attr(checked,> this.checked)
$('#multiple_msisdn').append('<label class="exp" style="margin-bottom: 5px; display: inline-block;"><input type="checkbox" class="exp SelectAll"> -- Select All -- </label>').append('<br><label class="exp" style="margin-bottom: 5px; display: inline-block;"><input type="checkbox" class="exp" name="msisdn[]"> -- 1 -- </label>').append('<br><label class="exp" style="margin-bottom: 5px; display: inline-block;"><input type="checkbox" class="exp" name="msisdn[]"> -- 2 -- </label>');
$(document).on("click",".SelectAll",function(){
$("input[name='msisdn[]']").prop('checked',$(this).is(':checked'))
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="multiple_msisdn"></div>
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