[問題] jQuery each --> Native Loop
最近在撰寫一個網頁
由於網頁中會動態產生大量表格資料
導致網頁會慢一些
翻了一下網路上關於 jQuery performance 的文章
看到把.each改用 javascript native loop 會快很多
嘗試修改卻改不出來
希望各位高手協助一下
簡單的程式碼如下
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
</head>
<body>
<div id="test">
<div id="a1"></div>
<div id="a2"></div>
</div>
<div id="debug"></div>
<script>
$(document).ready(function(){
$("#test").children("div").each(function(){
$("#debug").append("I got "+$(this).attr("id")+"<br/>");
});
});
</script>
</body>
</html>
程式會取得 DIV#test 接著把他底下的 DIV id列印出來
想把 $("#test").children("div").each 換掉改用for
這樣有辦法嗎?
感謝m(_ _)m
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.235.199.15
推
07/31 22:56, , 1F
07/31 22:56, 1F
→
07/31 22:57, , 2F
07/31 22:57, 2F
→
07/31 22:57, , 3F
07/31 22:57, 3F
→
07/31 22:58, , 4F
07/31 22:58, 4F
→
08/01 00:44, , 5F
08/01 00:44, 5F
討論串 (同標題文章)
以下文章回應了本文 (最舊先):
完整討論串 (本文為第 1 之 3 篇):