开发者

How to hide a label for="x01" checkbox using jQuery

开发者 https://www.devze.com 2022-12-28 00:36 出处:网络
I am attempting to开发者_Python百科 hide this checkbox, which is a check all checkbox in my table header, using jQuery but am not having much luck.

I am attempting to开发者_Python百科 hide this checkbox, which is a check all checkbox in my table header, using jQuery but am not having much luck.

The view source of the section I am trying to hide from the user is as follows:

<th class="t12subheader" id="CHECK$01"><label for="x01" class="hideMe508">Check All</label><input type="checkbox" name="x02" value="1" onclick="checkAll(this)" /></th>

I have tried both:

$('#x01, label[for="x01"]').hide ();  &
$('#x01').hide ();

to no avail.

Also, does it matter the positioning of hiding this checkbox?


Your label hiding is ok, however the checkbox won't work since it doesn't have id="x01", at least in your pasted code. It does have name="x02" so you can find/hide it via that, like this:

$('input[name="x02"], label[for="x01"]').hide();​

I'm guessing you meant the label to go with the input, in which case the checkbox should have a matching id to the label's for, like this:

<input type="checkbox" id="x01" name="x02" value="1" onclick="checkAll(this)" />

Then your selector would be:

$('#x01, label[for="x01"]').hide();


the for attribute doesn't count as an id. Give your label it's own id, something like "x01_label", and then you can easily hide it.

Your first attempt might work if you remove the #x01, from it. There's nothing in your code sample with an id of x01. Just select label[for="x01"]. If not then try the id thing instead.


From the code it seems you are trying to hide the label. Do this $("label.hideme508").hide(); No idea what is the class hideme508, but it should work.


$('#CHECK$01,label[for="x01"]').hide(); should work. your label is child of CHECK$01 and not x01

0

精彩评论

暂无评论...
验证码 换一张
取 消