我有一個用jquery編寫的嵌套循環,並且在我的子循環中返回false,從而將相同的文本附加到父行。我的代碼,每個循環都無法跳出jquery
$('#listingProducts ul.msRows li.msFullfillment').each(function(index) {
if(typeof $('#hfOrd'+index).val() != 'undefined'){
var $this = $(this);
var orderId = $('#hfOrd'+index).val();
// repainting logic
$('body').append(data);
$('#ajaxProducts ul.displayPoints li').each(function(index){
var $child = $(this);
if(typeof $('#hfAjaxOrderId'+index).val() != 'undefined'){
var ajaxOrderId = $('#hfAjaxOrderId'+index).val();
//alert(orderId+' '+ ' '+ajaxOrderId);
if(ajaxOrderId === orderId){
// replace the div here..
var anchorText = $child.find("#pointsLineAjax .redeem").text();
$this.find("#pointsLine .redeem").text(anchorText);
return false;
}
}
});
}
});
在子循環內部返回false不會返回到父級。這似乎並沒有寫入相應的行。我在這裏丟失什麼..
什麼是'$( '#hfOrd' +指數).VAL()'? –
創建一個小提琴來檢查發生了什麼。 –
@ ling.s它是現有行中的orderid,我正在比較從具有orderid的ajax返回的行,如果兩者都相同,我將替換文本。 – coderman