動態選擇我需要的「i」點擊功能取決於可變長度未知:jQuery的點擊
for(i=0;i<=unknownLength;i++)
{$("#group_link_"+i).click(function()
{//asynchronous call to a Web Service for the specific content on group_link_i div, here I will use $("#group_link_"+i).val()}
);}
此代碼不能正常工作。但是,相同的代碼,如果我刪除循環並複製「i」次以上的代碼,它的工作就完美了。
如何使用循環來實現此功能?
非常感謝
你是什麼意思與*不工作*?如果在回調中使用'$(「#group_link _」+ i).val()',那麼這是一個關閉問題。 – 2010-08-01 20:33:26
是的,我在裏面使用$(「#group_link _」+ i).val()。你的意思是「關閉問題」?非常感謝 – 2010-08-02 09:58:37