How to set the CheckBox check box to read-only:
check box checkbox does not have the ReadOnly property, but if it is set to not be available, that is, its disabled= "disabled", the checkbox value is not sent, and the appearance is grayed out, here is how to simulate the read-only state of the implementation check box.
One. Native JavaScript code:
ckobj.onclick=function() { returnfalse;}
That is, using return False to cancel the default behavior of the action, when the check box is clicked, the default behavior is to select or uncheck.
Two. The jquery code achieves this effect:
$ (function() { $ ("input[type= ' checkbox ']"). Click (function() { this. checked=! This . Checked; })})
The above code also implements our requirements, the method is very simple is to set the check box checked property value to the original state,! this.checked return is the check box is clicked on the opposite state, for example, before the click is selected, then the click is not selected, the opposite state is also selected.
Related reading:
1.[type= ' checkbox '] can refer to the [Attribute!=value] selector section of jquery .
2.checked properties can be found in the Checkbox.checked Properties section of JavaScript .
The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=9484
For more information, refer to: http://www.softwhy.com/jquery/
How to set the CheckBox check box to read-only