我想从价格中删除 25%
,然后在新范围中显示总和。像这样的事情:
price * 0.8 = newPrice //edited
这是我的跨度:
<span id="ctl00_main_ctl00_ctl00_labPrice" class="price" itemprop="price">21.188</span>
这是我到目前为止所想到的......
$(".purchase-block-price" ).each(function() {
// Show price ex vat
var price = parseInt($(".price").text().trim().replace(".",""));
var newprice = price * 0.8;
$(newprice).appendTo(".purchase-block-price");
});
这可能吗?
最佳答案
当然,获取该值(在本例中使用 text()
)并乘以 0.75。
var value = parseFloat( $("#ctl00_main_ctl00_ctl00_labPrice").text() );
var newValue = value * 0.75;
console.log( newValue );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id="ctl00_main_ctl00_ctl00_labPrice" class="price" itemprop="price">21.188</span>
关于javascript - 如何使用 jQuery 删除跨度数值的 25%?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42694539/