在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ jQuery中的 循環(huán)問題

jQuery中的 循環(huán)問題

我在點擊查看按鈕選獲取表格某條數(shù)據(jù)的id的時候,根據(jù)id請求多條數(shù)據(jù),使用each循環(huán)進行渲染,點擊完之后,下次點擊會累計上次的信息
這是我寫的代碼:

//查看數(shù)據(jù)的商品詳情頁的數(shù)據(jù)請求
function productDatas(orderNum,type) {

    $.ajax({
        type: 'post',
        data: {orderNo: orderNum},
        url: '/manages/order/query_orderno',
        success: function (data) {
            var item='';
            console.log(data);
            var goodsDatas=data.data.detailList;//goodstype
            console.log(data.data.detailList);
            $.each(goodsDatas,function(i,result){  ///<button type="button" id="lookOrderDatas" class="btn btn-primary">查看</button>
                item += '<tr height="50"><td>'+result.goodstitle+'</td><td>'+result.goodsid+'</td><td>'+result.quantity+'</td><td>'+result.totalprice+'</td><td  style="width: 80px" ><button type="button" id="lookOrderDatas" class="btn btn-primary" style="display: none">查看</button></td></tr>';
                if(result.goodstitle==1){
                    $("#lookOrderDatas").css("display","block");
                }
            });
            $('#productDatas').append(item);
        }
    })

}

這是我的圖片圖片描述

問題出現(xiàn)的環(huán)境背景及自己嘗試過哪些方法

相關代碼

// 請把代碼文本粘貼到下方(請勿用圖片代替代碼)

你期待的結果是什么?實際看到的錯誤信息又是什么?

回答
編輯回答
菊外人

你應該先清空在添加

2017年2月17日 01:48
編輯回答
野橘

意思是不是多次點擊查看,彈出的dialog內(nèi)容是累加的?$('#productDatas')請再append前執(zhí)行一次empty。

2017年12月31日 00:10
編輯回答
魚梓

木有太看懂啊,關鍵代碼圈出來,問題是啥,想要啥結果

2018年8月30日 08:15