突出显示使用AJAX返回数据填充的HTML表的行

How to get row value of a table on mouse click? Data in this table is populated from the data returned using AJAX.

Below is the code which is 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 I completely follow your question, your title and descriptions seem to conflict. Are you looking to get the value you a specific cell on click? Your question says you want the value of a row...

If I understand it correctly, you either want the value of a specific cell when it is clicked, or you want to highlight the row of that cell that you are clicking.

I have setup a codepen http://codepen.io/anon/pen/oXNeMx with a simple solution.

Depending on how the table is generated, you can put that javascript code into it's own function and call that function whenever you have new AJAX data so that the click handler gets bound to the table and elements.

//handles table cell click events
$('td').click(function(){

  //updates the value
  var cellValue = $(this).html();

  //find the row of table where cell was clicked
  var tr = $(this).closest('tr');

  //removes select class from all rows
  $(tr).siblings().removeClass('highlight');

  //adds class to highlight selected row
  tr.addClass('highlight');

});

The reason your code is not working is because you attach an event handler to some elements, but then you replace those elements with new ones from the AJAX call.

You need to set an event handler on an element that will not change, for example, the table (if you table gets replaced in its entirely, you need to find a higher ancestor that never changes).

// ancestor      event    real selector
$('#tblBdy').on('click', 'tbody td', function() {
    // Same code as yours in the handlers
});