[ACCEPTED]-Jquery - selectors - Selecting every element within a div-jquery-selectors
Accepted answer
The easier jQuery only selection would be 3 $("#divID *")
. As you know in CSS a b
means all b
which is 2 descendant of a
and a > b
means all b
which is direct child of a
so #myDiv *
means 1 everything that is a descendant of a <div>
with id="myDiv"
.
To get all children and descendents:
$('.SomeClass *')
To get 1 only direct children:
$('.SomeClass > *')
If you want absolutely every element within 1 .Someclass, use:
var allElements = $(".Someclass *");
This works in Chrome:
$(".Someclass *").addClass("testing");
0
or if you want everything not just direct 1 children. $('.someclass *')
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.