Since I’ve got more than one correct answer, I’m answering
Thanks for your help
this was the sollution here
$(‘body’).children(‘.class_to_find’);
Thanks
Sorry for bad formating of example, this markdown system in not good.
I may have more than 1 element with the same class in my document, but I need to just find those who are outside any element but body, example
<body>
<div class="class_to_find">my div</div>
<div class="testing">
<div class="class_to_find">my other div</div>
</div>
</body>
I just want to catch ‘my div’, but of course this
$('body').find('.class_to_find');
does catch all, since they’re all within body, what should I do?
Use the direct parent-child selector:
or
.children(), which only searches direct descendents: