我刚接触过Javascript。其实答案很简单,但我做不到
价格显示javascript代码;
$('#totalPricefark').html(data.totalPrice);Html
<strong id="totalPricefark">0</strong>我想做什么;
data.totalPrice * 0.6的计算与显示
谢谢
发布于 2018-10-26 06:17:47
javascript没有解决问题:(使用php创建了一个新的Json对象变量。就这样解决了。感谢我的朋友们。
发布于 2018-10-25 06:48:07
这将从priceFark div获取值,通过pareseInt函数将其解析为整数,然后乘以0.6并将数据填充到其他元素中。
解决方案使用jQuery,因为您最初的问题也在使用它。
试试这个:
var priceFark = parseFloat($("#totalPricefark").text());
$('#totalPricefark2').html(priceFark * 0.6);<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<strong id="totalPricefark">2</strong>
<br/>
<strong id="totalPricefark2">1</strong>
发布于 2018-10-25 08:05:10
尝尝这个
var data={};
data.totalPrice=15;
var result=(parseFloat( data.totalPrice) * 0.6);
$('#totalPricefark').html(result);<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<strong id="totalPricefark">0</strong>
https://stackoverflow.com/questions/52982964
复制相似问题