开发者

JQuery Mobile Loop to add items

开发者 https://www.devze.com 2023-02-09 05:47 出处:网络
How to loop and add list items in jQuery Mobile? 开发者_如何学编程Something like this I found using PHP:

How to loop and add list items in jQuery Mobile?

开发者_如何学编程Something like this I found using 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>";
  }

But I am not using PHP in my project (Using C# webservice,JqueryMobile). Assuming I need to add 5 list items which is stored in the variable Count, how can I achieve this in jQuery Mobile?

Any idea where I can find jQuery Mobile tutorials which uses C# web service to talk to database?

Thanks in advance...


Lucky for you, jQuery Mobile inherits all of jQuery's behaviors. For iterating over a collection, try using ".each()" like so:

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

jQuery is very well documented, and the relevant documentation for .each() is here: http://api.jquery.com/each/. Learn to love those docs.

0

精彩评论

暂无评论...
验证码 换一张
取 消