$('#all_locations').append("<table>");
$('#all_locations').append("<tr><th>City</th></tr>");
$.each(data, function(i, item){
$('#all_locations').append("<tr>");
$('#all_locations').append("<td>"+item.city+"</td>");
$('#all_locations').append("<tr>");
}
$('#all_locations').append("</table>");
輸出使用alert($('#all_locations').html());
jQuery附加表自動在文本末尾添加結束標記。爲什麼?
<table></table>
<tr><th>City</th></tr>
<tr></tr><td>Seattle</td>
<tr></tr><td>Chicago</td>
此代碼在ajax調用完成時觸發。任何想法爲什麼會這樣做?
假設數據變量是有效的JSON對象。
哇不知道..它有一定道理,但因爲每當我不關閉的append()內的標籤,它會做它對我來說......謝謝! – Sherzod