後啓用現場活動這是從以前的計算器jQuery的問題,我問的延續,但我不認爲這行:它已經死了
$(".insert").live("click", insertHandler);
工作。
<!DOCTYPE HTML>
<html>
<head>
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
function insertHandler(currentRow) {
var newRow = currentRow.clone(true);
newRow.children('td:last').empty().append('<input name="myid" />');
currentRow.after(newRow);
document.myForm.myid.focus();
}
function OnLoad() {
$('input[name="myid"]').live('focusout', function() {
var myValue = $(this).val();
var currentCell = $(this).parents("td");
currentCell.empty().append(myValue);
$(".insert").live("click", insertHandler); // I need help here
});
$('.insert').live('click', function() {
$('.insert').die();
var currentRow = $(this).parents("tr:first");
insertHandler(currentRow);
});
$('.delete').live('click', function() {
if (confirm("Are you sure?")) {
$(this).parents("tr").remove();
}
});
}
google.load("jquery", "1");
google.setOnLoadCallback(OnLoad);
</script>
</head>
<body>
<form name="myForm">
<table border="1">
<tr>
<td class="insert">Add</td>
<td class="delete">Erase</td>
<td>Sample data goes here</td>
</tr>
</table>
<input name="Other">
</form>
</body>
</html>
我希望用戶能夠添加一個新的行,但不要反覆點擊「添加」一遍又一遍。
在您的幫助下,我禁用了「添加」事件,但現在我無法啓用回覆功能。