简体   繁体   中英

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. I 'm able to hide the radio button but not the label. how can I hide the label.??

If you use jQuery:

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

Or with different markup:

HTML:

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

JS:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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