簡體   English   中英

腳本正在使用jquery 1.3.2但不適用於jquery 1.7.2

[英]Script is working with jquery 1.3.2 but not with jquery 1.7.2

我正在嘗試添加額外的輸入字段,但是一旦我嘗試使用jquery 1.7,這段代碼就可以使用jquery 1.3了。 它不起作用

var newTr = $(document.createElement('tr'))
         .attr("id", 'line' + counter);

    newTr.after().html('<td><input type="text" name="name' + counter + 
          '" id="name' + counter + '" value="" style="width:100px;"></td><td><input type="text" name="phone' + counter + 
          '" id="phone' + counter + '" value="" style="width:100px;"></td>');

    newTr.appendTo("#dyTable");

我猜newTr.after()。html()和newTr.appendTo(“#dyTable”)有問題; 請幫我

不需要document.createElement('tr') ,只需使用$('<tr></tr>')創建新元素即可。 這應該工作,

var newTr = $('<tr></tr>').attr("id", 'line' + counter);

要添加<td>內容, newTr.after().html('...')更改為newTr.html('...') 我不認為after是必需的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM