我正在尝试从具有类和/或 id 的 2 个父 div 中选择一个输入文本框。这样做的例子和方法太多了,我已经尝试了很多,以至于我不得不发布这个问题以寻求帮助,以防其他人可能遇到这个问题。
代码
<div class="tblsearch">
<div id="ElementCount10_filter" class="dataTables_filter">
<label>
Search:
<input type="text">
</label>
</div>
<div id="ElementCount10_info" class="dataTables_info"></div>
<div class="clear"></div>
</div>
我尝试了以下方法:
$(this).parent(".dataTables_filter").children("label").children("input").click(function () { alert('we got here'); });
$(".tblsearch.dataTables_filter label > input").click(function () {
alert('hovered');
});
$(this).parent(".dataTables_filter").children("input").click(function () { alert('we got here'); });
我一直无法访问选择器。我需要检查是否有人点击了该框并启动了某个功能。这看起来超级简单,我的语法中一定遗漏了一些东西。
在此先感谢您的帮助!