开发者

Need help to build my selector

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜