爲什麼此代碼無法正常工作?含義沒有顯示到ul標籤中。eq fliter無法正常工作
$("#server").each(function()
{
var textValue = $(this).text();
$('#list li').eq(counter).append('<li>' + textValue + '</li>'); // <-- not working
$('#list li').eq(counter).insertAfter('<li>' + textValue + '</li>'); // <-- or not working
$('#list')append('<li>' + textValue + '</li>'); // <-- or working
});
<div>
<ul id="list"></ul>
</div>
'counter'在哪裏申報? –
你是不是指'.each(function(counter){...});'另外,#server是一個id,應該只發生一次。如果你的意思是一個類,'.server'應該被用作選擇器。 – Matijs
您是否收到錯誤訊息? –