I have following html
<table>
<th>Name</th><th>age</th>
<tbody>
<tr><td>A</td><td>25</td></tr>
<tr><td>B</td><td>30</td></tr>
<tr><td>C</td><td>34</td></tr>
<tr><td>D</td><td>32</td></tr>
</tbody>
</table>
I want to select all tr inside tbody. Hence I used:
$('table tbody tr').css('background-color','yellow');
Highlight all TRs inside TBODY inside Table with yellow.
This shouldn’t select TH row, but it strangely does and highlights it yellow. Any thoughts!
thanks
Your markup isn’t 100% valid so the browser is fixing it for you. See the spec for the allowed
<table>structure.Wrap the
<th>elements in a<thead>.