javascript - Highlighting row of a HTML table which is populated using AJAX return data -


how row value of table on mouse click? data in table populated data returned using ajax.

below code not working:

$('table#tblbdy tbody tr').click(function() {    $('tr').click(function () {      var tabledata = $(this).closest("tr").children("td").map(function() {       return $(this).text();    }).get();    $('#bx1txt').val($.trim(tabledata[0]));    $('#bx2txt').val($.trim(tabledata[1]));    $('#oldqty').val($.trim(tabledata[1])); }); 

i'm not sure follow question, title , descriptions seem conflict. looking value specific cell on click? question says want value of row...

if understand correctly, either want value of specific cell when clicked, or want highlight row of cell clicking.

i have setup codepen http://codepen.io/anon/pen/oxnemx simple solution.

depending on how table generated, can put javascript code it's own function , call function whenever have new ajax data click handler gets bound table , elements.

//handles table cell click events $('td').click(function(){    //updates value   var cellvalue = $(this).html();    //find row of table cell clicked   var tr = $(this).closest('tr');    //removes select class rows   $(tr).siblings().removeclass('highlight');    //adds class highlight selected row   tr.addclass('highlight');  }); 

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -