我正在构建的控件包含一个可滚动的表,它有一个问题。这些行建立了一个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>');
当成功添加行时,出于某种原因,静态行与单击处理程序一起工作,但新添加的行不工作。我有什么东西不见了吗?