Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select all child elements of specified control using jQuery

I have a <table id="myTable"> with a number of child elements:

<tr><td>
   <span class="mySpan" />
</td></tr>
<tr><td>
   <span class="mySpan" />
</td></tr>
<tr><td>
   <span class="mySpan" />
</td></tr>

How to select all this spans using jQuery?

like image 304
abatishchev Avatar asked Dec 10 '22 16:12

abatishchev


1 Answers

Note that you COULD do any of the following:

$("#myTable").find(".mySpan");
$("#myTable .mySpan");
$("#myTable tr td .mySpan");
$("#myTable").find("tr").find("td").children(".mySpan");
$(".mySpan");
$("#myTable > tr > td > .mySpan");
$(".mySpan ,#myTable");
like image 161
Mark Schultheiss Avatar answered Mar 30 '23 00:03

Mark Schultheiss