jQuery,ID中类的选择器 [英] jquery, selector for class within id

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

问题描述

下面,我该如何选择包含id = "my_id"的元素中包含类my_class的元素?

Below, how should I select the elements that contain the class my_class within the element with id = "my_id"?

请注意,该元素可能还具有另一个类,我没有为此选择.

Note that the element may also have another class, which I am not selecting for.

<div id = "my_id">
    <span class = "my_class hidden">hi</span>
    <span class = "my_class">hello</span>
</div>

正在尝试

$("#my_id [class*=my_class ]")

推荐答案

您可以将类选择器后代选择器

$("#my_id .my_class")

这篇关于jQuery,ID中类的选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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