元素类型和类名的Jquery选择器? [英] Jquery Selector for Element type and Class name?

查看:134
本文介绍了元素类型和类名的Jquery选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个元素,我们将调用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆