-1

How to remove <tr> onclick method if child <td>&nbsp;</td> or <td></td> using jquery ?

  <tr title="Click to select row" class="gridItem" 
             onclick="javascript:__doPostBack('ctl00$Body$grdComments','Select$0')">
        <td>&nbsp;</td>
        <td>&nbsp;</td>
       </tr>
  <tr title="Click to select row" class="SelectedRowStyle" 
             onclick="javascript:__doPostBack('ctl00$Body$grdComments','Select$0')">
        <td>&nbsp;</td>
        <td>&nbsp;</td>
       </tr>
James123
  • 11,184
  • 66
  • 189
  • 343

1 Answers1

1

.text returns the (decoded) content of the element, so you just have to test whether a tr element only contains spaces or is empty:

$('tr').filter(function() {
    return /^\s*$/.test($(this).text());
}).prop('onclick', null);

Also see How to remove "onclick" with JQuery?.

Community
  • 1
  • 1
Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143