[問題] 請教jQuery迴圈的問題 !

看板Ajax作者 (Killuaza)時間15年前 (2008/10/28 11:33), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
各位先進好 小弟目前有一小段程式有問題 對jQuery 還不是很熟 ,還請大家多多幫忙 ! for(var i=1;i<best.length;i++){ if(i<10){ document.write("<td id=zone0-"+ i + " width=60 align='center'>0" + i + "</td>"); }else{ document.write("<td id=zone0-"+ i + " width=60 align='center'>" + i + "</td>"); } if((i%10)==0)document.write("</tr><tr>"); $("td#zone0-"+i).click(function(){ if($(this).css("background-color")=='red'){ $(this).css("background-color","white"); zoneInput[0]--; best[i]--; }else{ if(zoneInput[0]>=max){ alert('Over Max'); }else{ $(this).css("background-color","red"); zoneInput[0]++; best[i]++; } } }); } 我想做的就是在一表格內點任一數字 然後該數字就會做加總 但在 .click(function 裡,迴圈的 i 值都是固定 為 81 (best.length=80) 這是為什麼咧 ? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.248.130.139
文章代碼(AID): #191eWLhr (Ajax)
文章代碼(AID): #191eWLhr (Ajax)