复选框标签的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 库
这篇关于复选框标签的jQuery选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文