Table click function called twice

751 Views Asked by At

I am performing some operation on the event of any td cell click in the table I call the below function:

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

    if ($(row).text().trim() == "") {
        row = this.parentNode.cells[0];
    }
    var rowvalue = $(row).text();
    var columnvalue = $(column).text();
    alert(rowvalue, columnvalue);
})

The function gets called twice. What ever operation I perform inside the function is being done twice. Can you please advise. The alert comes twice

1

There are 1 best solutions below

0
On BEST ANSWER

$('#tablename').off('click','td').on('click', 'td', function(e){ } I Changed the function like this and it worked