2011-02-09 72 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/。学会喜欢那些文档。