javascript - Filter td elements in a tr out, that are not displayed -


i have datatable in asp.net want modifiy. select <tr> rows of datatable jquery:

var rows = $("#dginformation tr:gt(0)"); 

however, <tr>elements have multiple <td>elements , of them marked display:none. how can rows-variable without hidden cells?

the purpose of check cells if different each other , 1 line each difference should displayed. if dont filter not displayed elements, compared , have lines, visually same.

update works adding css class <td>-elements should hidden. have clean dom-tree (i hope can call way) in firebug. whole function below reference:

function filtertable()  {                var rows = $("#dginformation tr:gt(0)");         var prevrow = null;         var counter = 2;         rows.each(function (index) {             if (prevrow !== null) {                 var = 1;                 var changes = 0;                 $(this).children("td:visible").each(function () {                     if(i > 2){                         if ($(':nth-child(' + + ')', $(prevrow)).html() != $(this).html())                          {                             $(':nth-child(' + + ')', $(prevrow)).css('backgroundcolor', '#00ff00');                             changes = changes + 1;                             }                     }                     i++;                 });                 if(changes == 0)                 {                     $(prevrow).css('display','none');                     $(prevrow).removeclass();                        }                                  else                 {                     $(prevrow).removeclass();                            if(counter % 2 == 0)                         $(prevrow).addclass('dgitemstyle');                     else                         $(prevrow).addclass('dgalternatingitemstyle');                     counter = counter + 1;                 }               }             prevrow = this;         });     } 

you can use :not() filter this.

if have html like

<table id='tableid'>     <tr><td></td>         <td class="hidden">hidden cell</td>         <td>3</td>         <td>4</td></tr>     <tr>         <td>5</td>         <td class="hidden">hidden cell</td>         <td>6</td>         <td>7</td>     </tr>     <tr>         <td>8</td>         <td class="hidden">hidden cell</td>         <td>9</td>         <td>1</td>     </tr> </table> 

css:

.hidden{     display:none; } 

script: if u want td elements in table without hidden td elements then,

var rows = $("#dginformation tr:gt(0) td:not('.hidden')"); 

it work!!


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -