Checkbox set true, false. Checkbox click event on jQuery and JS.
How set checkbox on the true or false.
Checkbox set true. Use attribute checked.
<input type="checkbox" checked>
Checkbox set false. Don’t use the checked attribute
<input type="checkbox">
Controlling the checkbox for jQuery.
Uncheck the checkbox on jQuery.
// add checked $('#checkbox_spage').prop('checked', true) // delete checked $('#checkbox_spage').prop('checked', false)
Simulate a click on a checkbox.
$('#checkbox_spage').trigger('click');
Check the status of the checkbox on mouse click.
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <P"><input type="checkbox" id="checkbox_spage"> Show form Dialog Client on your site.</P> <SCRIPT> $("#checkbox_spage").click(function(){ if ($(this).is(":checked")){ alert("checked true - 1"); } else { alert("checked false - 0"); } }); </SCRIPT>
Controlling the checkbox for Java Script.
Check the status of the checkbox on mouse click.
<P><input type="checkbox" id="checkbox_spage"> Show form Dialog Client on your site.</P> <SCRIPT> var el = document.getElementById("checkbox_spage"); el.onclick = function () { if (el.checked) { alert("checkbox_spage 1"); } else { alert("checkbox_spage 0"); }; }; </SCRIPT>
Categories: