我没有Math.round(num * 100) / 100
上班。我使用普通的jQuery,但我不明白。感谢您的帮助。谢谢!
此脚本可转换长度,其效果完美
<script>
var meters = document.getElementsByClassName("num");
for (var i = 0; i < meters.length; i++) {
meters[i].innerHTML = parseInt(meters[i].innerHTML) * 3.2808399;
}
</script>
<p class="num">12</p>
<p class="num">7</p>
答案 0 :(得分:1)
类似的东西???? 我不确定您要做什么。...
var meters = document.getElementsByClassName("num");
for (var i = 0; i < meters.length; i++) {
meters[i].innerHTML = Math.round(parseInt(meters[i].innerHTML) * 3.2808399 * 100) / 100
}
<p class="num">12</p>
<p class="num">7</p>