javascript - How to set a css class to table header cell -
i have table thead cells. want set css class 'th' value of 'th' "id".
i tried :
var t = []; $('.tbl > thead > tr > th').each(function(){ t.push($(this).text()) }) (var = 0; < t.length; i++) { if (t[i] == "id" ) {$('.tbl thead tr th').addclass('myclass')}; }
but code set class 'myclass' headers of table.
<thead> <tr> <th class="myclass">id</th> <th class="myclass">nom</th> </tr> </thead>
here fiddle --> http://jsfiddle.net/1ck4joum/1/
thanks.
use this
$('.tbl thead tr th:contains("id")').addclass('myclass')};
Comments
Post a Comment