Javascript – Disable click event on HTML table cell

htmljavascriptjquery

How to disable click on a table cell when the cell is empty or has value as zero.
I have a table in which when i click on a particular cell certain operations are performed. But I want the click event not to work when the table has cell value 0 or empty cell

$('#tablename').off('click','td').on('click', 'td', function(e) { 
    var column = e.delegateTarget.tHead.rows[0].cells[this.cellIndex];
    var row = this.parentNode.cells[1]; 

    if ($(row).text().trim() == "")
    {
        row = this.parentNode.cells[0]; 
    }

    var rowvalue = $(row).text();
    var columnvalue = $(column).text();
}

Best Solution

$('td').click(function(){
   var v = $(this).html();
   if( $.trim(v) != '0' && v != '' ){
      // your code
   }
});

hope this helps you.