利用 $.inArray,數組去重

來源:互聯網
上載者:User

標籤:new   inf   數組   one   UNC   round   find   添加   sea   

var WarnInfo = new BatchInfo();
//點擊返回按鈕,查詢彈窗消失,添加彈窗出現
$(".search_cancel2").click(function () {
// var allCheckedb = $("body .demo_contenta2 tr:has(input:checked)");
var allCheckedb =$("body .demo_contenta2 tr[id!=‘nocc‘]:has(input:checked)");
for (var a = 0; a < allCheckedb.length; a++) {
var allCheckedC = $(allCheckedb[a]);
for (var b = 0; b < WarnInfo.id.length; b++) {
if (allCheckedC.attr(‘data-id‘) == WarnInfo.id[b]) {
var index = $.inArray(WarnInfo.id[b], WarnInfo.id);//擷取某個數值在數組當中的索引
WarnInfo.id.splice(index, 1);
WarnInfo.code.splice(index, 1);
WarnInfo.name.splice(index, 1);
WarnInfo.unit.splice(index, 1);
WarnInfo.inventory.splice(index, 1);
WarnInfo.xia.splice(index, 1);
WarnInfo.numberOne(index,1);
}
}
WarnInfo.id.push(allCheckedC.attr("data-id"));
WarnInfo.code.push(allCheckedC.find("td:eq(2)").html());
WarnInfo.name.push(allCheckedC.find("td:eq(3)").html());
WarnInfo.unit.push(allCheckedC.find("td:eq(4)").html());
WarnInfo.inventory.push(allCheckedC.attr("data-inventory"));
WarnInfo.numberOne.push(allCheckedC.attr("data-number"));
WarnInfo.xia.push("請輸入");
}
for迴圈判斷出重複的內容,然後擷取它在數組中的索引,數組去重。

利用 $.inArray,數組去重

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.