Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hai all,

I have the list of checkbox with same ID like this,

<input id='CheckBox1' class='chkbxq' type='checkbox' name='chkOrder' />
<input id='CheckBox1' class='chkbxq' type='checkbox' name='chkOrder' />
<input id='CheckBox1' class='chkbxq' type='checkbox' name='chkOrder' />
<input id='CheckBox1' class='chkbxq' type='checkbox' name='chkOrder' />

and i want to hide this checkbox using ID, i tried this code $("#CheckBox1").attr("disabled", true); but the first checkbox only disabled others are enabled. what can i do for hide these all the four checkboxes any help please.

Regards
Sampath
Posted
Updated 12-Nov-13 23:58pm
v2

Your code
$("#CheckBox1").attr("disabled", true);

doesn't work because jQuery expects only one element matching a specific ID. Your HTML is invalid; the IDs of elements need to be unique. Change your HTML and have the jQuery selector use a class or the "name" attribute. You should also be disabling them with prop() instead of attr():
$(".chkbxq").prop("disabled", true);

OR
$("input[name='chkOrder']").prop("disabled", true);
 
Share this answer
 
v3
Hi check the solution

JavaScript
$(".chkbxq").attr("disabled", true);


have a look of this link also
http://stackoverflow.com/questions/2330209/jquery-checkbox-enable-disable[^]
http://stackoverflow.com/questions/19162913/disabling-checkbox-using-jquery[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900