html:
<p>Order</p>
<div>
<ul data-role="listview" id="myorder"></ul>
</div>
JS:
itemName = ["beer1", "beer2", "beer3", "beer4"];
itemQty = [0, 2, 0, 4];
for ( var i=0, len=itemName.length; i<len; ++i) {
if (itemQty[i] > 0) {
var listItem = document.createElement("li");
listItem.innerHTML = itemName[i] + " Qty:" + itemQty[i];
$('#myorder').append(listItem);
$('#myorder').listview('refresh');
}
}
我知道它正盯着我的脸,但为什么这只显示我的第一个实例Qty > 0
?