你也可以做這樣的事情:
<table id="Table1">
<tbody>
<tr id="tr1">
<td>
The TD: <input type="button" id="button1" value="dothis"/>
</td>
</tr>
<tr id="tr2">
<td>
The TD: <input type="button" id="Button2" value="dothis"/>
</td>
</tr>
</tbody>
</table>
支持JS
$('#Table1 tr').bind('click', function(ev) { return rowClick($(this), ev); }); //Bind the tr click
$('#Table1 input').bind('click', function(ev) { return buttonClick($(this), ev); }) //Bind the button clicks
function rowClick(item, ev) {
alert(item.attr('id'));
return true;
}
function buttonClick(item, ev) {
alert(item.attr('id'));
ev.stopPropagation();
return true;
}
最終,點擊上的行是選擇操作,而按鈕的onclick是刪除操作。我一直無法找出做這種作品的好方法。 – JamesEggers 2009-04-14 00:24:28