来大神帮忙看看
javascript吧
全部回复
仅看楼主
level 2
javascript:(function(){ var z=0.4747,f=0,p0=1,p1=2,p2=4; var obj=document.getElementsByClassName("next-table-body")[1]; var tr=obj.getElementsByClassName('next-table-row'), v, price; for(var i=0,l=tr.length;i<l;i++){ price=tr[i].children[p0].innerText; v = tr[i].children[p1].children[0].children[0].children[0].children[0].children[0]; v.value=price; v.setAttribute("data-initvalue",price); v.setAttribute("value",price); v.dispatchEvent(new Event('blur', { bubbles: true })); price = parseFloat(price*z).toFixed(f); v = tr[i].children[p2].children[0].children[0].children[0].children[0].children[0]; v.value=price; v.setAttribute("data-initvalue",price); v.setAttribute("value",price); v.dispatchEvent(new Event('blur', { bubbles: true })); } document.getElementsByClassName('next-btn next-btn-primary next-btn-medium')[1].click(); })();
这是我用来修改多商品sku价格设定使用的 ,怎么修改成 不四舍五入 例如抓取价格为2888 折扣为0.475 2888*0.475=1371.8 返回文本框的去小数数值为 1372 怎么在这个一步里面去掉小数后的四舍五入 使数值返回为1371
2020年12月04日 08点12分 1
level 12
那用parseInt() 别用parseFloat() 这样toFixed()也不需要了
price = ~~(price * z); // 或者parseInt都用不上 反正是去掉小数是吧
2020年12月04日 10点12分 3
挖坟来啦[笑眼]谢谢大佬们 经查询资料改成向下取整函数完美 只是现在阿里后台好像更新了,已经无法使用了
2021年06月07日 08点06分
1