我有以下的jQuery代码。
var destTable = $("#numbers");
$(document).ready(function() {
$("#btnAdd").click(function() {
//Take the text, and also the ddl value and insert as table row.
var newRow = $("<tr><td>hi</td></tr>");
$("#numbers").append(newRow);
});
});
我真正想要的是只存储一个元素的引用,然后从那里使用它。
上面的代码按预期向表中添加了一行,但如果我使用$(destTable).append(newRow)
或destTable.append(newRow)
,什么都不会发生,有人可以为我解释一下吗?
谢谢