开发者

Need help to build my selector

开发者 https://www.devze.com 2023-01-26 10:24 出处:网络
Here is my JS code: <script&g开发者_如何学编程t; var my_var = $(this).parent(); // not important what \'my_var\' really is

Here is my JS code:

<script&g开发者_如何学编程t;
var my_var = $(this).parent(); // not important what 'my_var' really is
</script>

I would like to create a jQuery selector to select all children elements of 'my_var' element which have the class 'class_1' and 'class_2'.

I know I have to use '>' for children but my problem is that I have 2 classes ('class_1' and 'class_2') and my basic element is defined by a var ('my_var').

Thanks in advance for your help!


$("#" + my_var).children(".class_1.class_2")

If my_var is a jQuery element then just

my_var.children(".class_1.class_2")


Just a small typo fix (no need for double quotes after my_var):

jQuery("#" + my_var).children(".class_1.class_2")
0

精彩评论

暂无评论...
验证码 换一张
取 消