创建并使用{号码数组} jQuery中移动,以显示在列表视图内容 [英] Create and use a {NUMBERS array} in jQuery mobile to display content in a list view
问题描述
我使用jQuery Mobile和PhoneGap的实现一个iPhone应用程序,并希望实现一个列表视图,而无需使用硬codeD数据统计。
I'm using jQuery mobile and Phonegap to implement an iPhone app and want to implement a list view, without using hard coded data statistically.
<ul data-role="listview" data-inset="true" class="ui-listview">
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
不喜欢上面的硬code。
Not like the above hard code.
我需要创建像与数字的列表(一个,两个,三个,四个,五个等)的阵列的对象,并使用该数字阵列我想在填充到一个列表视图。这怎么可能创建和使用数组中的jQuery移动显示在列表视图中的内容。
I need to create an object like an array with list of numbers (one, two, three, four, five, etc.), and using that numbers array I want to populate in to a list view. How is it possible to create and use an array in jQuery mobile to display content in a list view.
推荐答案
您想要做这样的事情:
var NUMBERS = ["one", "two", "three", "four", "five"];
for (var i=0; i < NUMBERS.length; i++) {
$('#idofmylist').append($('<li/>', {
'id': id
}).append($(NUMBERS[i]))));
}
您将需要给你UL,你可以参考添加了礼的使用jQuery的追加一个ID。
You'll need to give you "ul" an id that you can reference to add the "li"'s using jQuery's append.
这篇关于创建并使用{号码数组} jQuery中移动,以显示在列表视图内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!