I need this kind of div
<div id="out">
<table id="tab">
<tr><th>A</th></tr>
<tr><td>B</td></tr>
</table>
</div>
and at a certain point I need to execute this instruction:
$("#out > #tab > tr > td").css( "background-color", "rgb(0, 255, 0)");
because I need all the td to have a green background.
If instead of #out>td I use either #out or td it works fine, but not like this. Can you tell me why?
jQuery library is already included.
$("#out > #tab > tr > td").css("background-color", "rgb(0, 255, 0)");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="out">
<table id="tab">
<tr>
<th>A</th>
</tr>
<tr>
<td>B</td>
</tr>
</table>
</div>
$("#out > td")>in a css selector specifies a direct descendent. td is not a direct descendent here. Remove it and it will find the td.#out > #tab > tr > td