有没有一种简单的方法可以通过 jquery 或 JavaScript 将下面的 DKK 代码量增加 20%。
<div id="priceInfo">
<span id="ctl00_bc_lblHtmlVariantPrice"><div class="current price"><span class="first">195,00 DKK</span></div>
我已经尝试过 div.,但无法使其工作。
希望能帮到大家
最佳答案
这有效。您只需将变量percentage
设置为您想要的折扣百分比。如果您要添加更多价格标签,它也适用。只需确保它们具有 .price
类即可。
$(document).ready(function(){
var percentage = 20;
$('.price').each(function(){
var cur = parseFloat($(this).text());
$(this).text(cur*(1-(percentage/100))+" DKK");
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<span id="ctl00_bc_lblHtmlVariantPrice"><div class="current price"><span class="first">195,00 DKK</span></div>
关于javascript - 如何将产品页面编号添加 20%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31192959/