i am trying to select/unselect all checkbox by checking one master checkbox inside my bootstrap modal, but javascript/jquery script not working with input type checkbox.
here is my html code-
<input type="checkbox" id="checkAll"/>
here is jquery-
$(document).ready(function() {
$("#checkAll").change(function () { alert('here');
$("input:checkbox").prop('checked', $(this).prop("checked"));
});
});
when i check on checkbox it doesn't show alert.
why this not working in bootstrap modal?
I've tried to show alert inside input tag like this-
<input type="checkbox" id="checkAll" onclick="alert('hello');"/>
which also not works!
Rohit Azad Malik :
Try to this way used to .on\n\n\r\n\r\n$(document).ready(function() {\r\n $(\"#checkAll\").on('change', function () { alert('here');\r\n var inputCheck =$(this);\r\n console.log(\"Checked -\"+inputCheck .is(\":checked\"));\r\n \r\n });\r\n});\r\n<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js\"></script>\r\n<input type=\"checkbox\" id=\"checkAll\"/>",
2015-12-21T11:40:31
Clemens Himmer :
This might be cause by not using .on.\n\nSee my JSFiddle that will explain your situation.",
2015-12-21T11:50:02