Here let us assume that we have an HTML mark up as follows
- <table Id="YearlyGridReport">
- <tr level="1">
- <td >Header Row1</td>
- <th ><span>2014</span></th>
- <th><span>2015</span></th>
- </tr>
- <tr level="2">
- <td >Header Row2</td>
- <th ><span>2014</span></th>
- <th><span>2015</span></th>
- </tr>
- <tr>
- <td >Header Row2</td>
- <th ><span>2014</span></th>
- <th><span>2015</span></th>
- </tr>
- ......
- </table>
Now what if to select the elements with the specific attribute. You can do that in the following way.
- var levelselector = $("#YearlyGridReport tr[level]");
- var levelcount = levelselector.length;