我正在构建的控件存在问题,该控件包含一个可滚动主体的表.这些行具有一个click()函数处理程序,该处理程序的建立方式如下:
/**
* This function is called when the user clicks the mouse on a row in
* our scrolling table.
*/
$('.innerTable tr').click (function (e) {
//
// Only react to the click if the mouse was clicked in the DIV or
// the TD.
//
if (event.target.nodeName == 'DIV' ||
event.target.nodeName == 'TD' ) {
//
// If the user wasn't holding down the control key,then deselect
// any prevIoUsly selected columns.
//
if (e.ctrlKey == false) {
$('.innerTable tr').removeClass ('selected');
}
//
// Toggle the selected state of the row that was clicked.
//
$(this).toggleClass ('selected');
}
});
有一个按钮可以向表中添加行,例如:
$('#innerTable > tbody:last').append('<tr>...some information...</tr>');
最佳答案
原文链接:https://www.f2er.com/jquery/531026.html