简体   繁体   English

用于元素类型和类名的Jquery选择器?

[英]Jquery Selector for Element type and Class name?

I have an element we'll call selectedTable that contains this innerHtml : 我有一个我们称之为selectedTable的元素,它包含这个innerHtml

<TBODY>
    <TR>
        <TD></TD>
        <TD></TD>
        <TD class='ms-cal-nav-buttonsltr'></TD>
    </TR>
</TBODY>

I'm trying to use JQuery selectors to return the <TD> tag with the "ms-cal-nav-buttonsltr" class. 我正在尝试使用JQuery选择器返回带有“ms-cal-nav-buttonsltr”类的<TD>标记。 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. 我发现$(selectedTable).find("TD")按预期返回表中的所有TD标签,但我想知道如何将TD元素选择器与类选择器结合起来。 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. 我试过$(subnode).find("TD").find(".ms-cal-nav-buttonsltr")$(subnode).find("TD .ms-cal-nav-buttonsltr")来没有用,但那些只是在黑暗中拍摄。 What's the most efficient way to accomplish this? 实现这一目标的最有效方法是什么? Thanks in advance. 提前致谢。

Just concatenate the two: 只是将两者连接起来:

$(selectedTable).find("td.ms-cal-nav-buttonsltr");

the selectors you tried were looking for a .ms-cal-nav-buttonsltr element underneath the td . 您尝试过的选择器正在寻找td下面的.ms-cal-nav-buttonsltr元素。

$('td.ms-cal-nav-buttonsltr', selectedTable);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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