-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
  • 10,572
  • 61
  • 180
  • 329

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
  • 756,363
  • 169
  • 1,062
  • 1,111