用于复选框标签的jQuery选择器 [英] jQuery selector for the label of a checkbox
本文介绍了用于复选框标签的jQuery选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<input type="checkbox" name="filter" id="comedyclubs"/>
<label for="comedyclubs">Comedy Clubs</label>
如果我有一个带有描述它的标签的复选框,我该如何使用jQuery选择标签?是否更容易给标签标签一个ID,并选择 $(#labelId)
?
If I have a check box with a label describing it, how can I select the label using jQuery? Would it be easier to give the label tag an ID and select that using $(#labelId)
?
推荐答案
这应该可以工作:
$("label[for='comedyclubs']")
另请参见: Selectors / attributeEquals - jQuery JavaScript Library
这篇关于用于复选框标签的jQuery选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文