2011-02-09 65 views
1

如何在jQuery Mobile中循環和添加列表項目?JQuery Mobile Loop添加項目

像這樣的事情,我發現使用PHP:

while($row = mysql_fetch_array($result)) 
    { 
     echo "<li><h2>" . $row['post_title'] . "</h2>" . $row['post_content'] . "<p class='ui-li-aside'>" . $row['post_date'] . "<strong></p>"; 
    } 

,但我不是在我的項目中使用PHP(使用C#web服務,JqueryMobile)。假設我需要添加5個存儲在變量Count中的列表項,那麼我如何在jQuery Mobile中實現這一點?

任何想法,我可以找到jQuery Mobile教程,它使用C#web服務與數據庫交談?

在此先感謝...

回答

0

幸運的是,jQuery Mobile的繼承所有jQuery的行爲。對於遍歷集合,請嘗試使用「每()」,例如:

$(count).each(function(index) { 
    // Add item to container here 
}); 

jQuery是非常有據可查,並.each()相關文件是在這裏:http://api.jquery.com/each/。學會喜歡那些文檔。