元素类型和类名的Jquery选择器? [英] Jquery Selector for Element type and Class name?
问题描述
我有一个元素,我们将调用 selectedTable
,其中包含 innerHtml
:
I have an element we'll call selectedTable
that contains this innerHtml
:
<TBODY>
<TR>
<TD></TD>
<TD></TD>
<TD class='ms-cal-nav-buttonsltr'></TD>
</TR>
</TBODY>
我试图使用JQuery选择器返回< TD&
标记与ms-cal-nav-buttonsltr类。我发现 $(selectedTable).find(TD)
返回表中的所有TD标签,如预期的,但我想知道我可以去将 TD
元素选择器与类选择器组合。我尝试了 $(subnode).find(TD)。find(.ms-cal-nav-buttonsltr)
和 $ (subnode).find(TD .ms-cal-nav-buttonsltr)
无效,但那些只是在黑暗中的镜头。什么是最有效的方法来完成这个?提前感谢。
I'm trying to use JQuery selectors to return the <TD>
tag with the "ms-cal-nav-buttonsltr" class. I've found that $(selectedTable).find("TD")
returns all the TD tags in the table as expected, but I'm wondering how I might go about combining the TD
element selector with a class selector. I've tried $(subnode).find("TD").find(".ms-cal-nav-buttonsltr")
and $(subnode).find("TD .ms-cal-nav-buttonsltr")
to no avail, but those were just shots in the dark. What's the most efficient way to accomplish this? Thanks in advance.
推荐答案
只要连接两个:
$(selectedTable).find("td.ms-cal-nav-buttonsltr");
您尝试的选择器正在查找 .ms-cal-nav- buttons $
元素。 td
下面的buttonsltr
the selectors you tried were looking for a .ms-cal-nav-buttonsltr
element underneath the td
.
这篇关于元素类型和类名的Jquery选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!