dubbs dubbs - 7 months ago 15
Javascript Question

jQuery Hide TDs without specified content

Looking for a way to hide the

td
s in a
table
which don't contain the inline CSS attribute
width:12%;


code example below.

<td class="" id="">
<td class="" id="">
<td class="" id="">
<td width="12%" class="" id=""><!-- don't hide me! --></td>


So, the first 3
td
s should get hidden only...

Answer

You can do it easier with CSS, but since you asked for a jQuery solution, something like this should work..

$('document').ready(function(){
    $.each($('td'),function(){
      if ($(this).attr('width') !== "12%") {
          $(this).hide();
      }
    });
});