简体   繁体   English

如何在javascript中隐藏对“ for”属性具有特定值的标签标记?

[英]How to hide a label tag in javascript that has a certain value for the “for” attribute?

The label's "for" attribute has the ID of a Radio button. 标签的“ for”属性具有单选按钮的ID。 I 'm able to hide the radio button but not the label. 我可以隐藏单选按钮,但不能隐藏标签。 how can I hide the label.?? 如何隐藏标签??

If you use jQuery: 如果您使用jQuery:

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

Or with different markup: 或使用不同的标记:

HTML: HTML:

<label for="radio"><input type="radio" id="radio"> Radio</label>​

JS: JS:

$('label[for="radio"]').hide();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM