try{ var G_stocksArr = jQuery.parseJSON('{"15235-0":1,"36178-0":2,"24658-0":146,"24573-0":295,"21199-0":172,"21161-0":145,"477589-0":4,"7321-0":3,"331307-283928":3,"308257-215178":1,"608936-0":1611,"564870-682500":7,"558855-662530":3,"537764-592383":4,"608202-860332":9,"344438-307357":1,"454538-424389":21,"440975-402157":1,"326762-265708":20,"320637-418435":3,"621626-916379":19,"621623-916365":12,"621623-916370":21,"690608-0":10,"657612-1017211":2,"653098-0":4,"652889-0":38,"652283-1002557":11,"652073-1002047":17,"632113-0":7,"304438-207598":8,"203383-80989":39,"47330-0":2,"641508-970965":1,"318410-239388":4,"434402-4544028":6}'); }catch(e){ var G_stocksArr = {}; $.ajax({ type:'gets', url:'https://www.beads.us/app/gets/awesomeTool.php?act=delStocks', success:function(msg) { console.log("删除库存,成功生成",e); } }); } $(".stocks_remaining").each(function(){ var $this = $(this); var key = $this.data('key'); $this.text(G_stocksArr[key]); var count=1; if(G_stocksArr[key] >100){ count=100; }else{ count=G_stocksArr[key] } $('#input_'+key).val(count); if(G_stocksArr[key] == 0){ $("#li_"+key). find('.bg_img').addClass('overlay').end(). find('.product_inventory').css('display','none').end(). find('.product_size').css('display','none').end(). find('.product_box_title').removeClass('product_box_title').addClass('product_box_title_stocks').end(). find('.product_size').addClass('change').end(); } } )