<input class="red" id="LR2" type="text" value="1" >
<p id="demo"></p> <br>
这是我的 JS 代码:
<script>
var price3 = 7; <br>
var price4 = 8; <br>
var selectValue = function RedAlert(data) { <br>
if( $("#LR2").val() = 0) { <br>
var price1 = 5; <br>
} <br>
else { <br>
var price2 = 6; <br>
} <br>
} <br>
var total = selectValue + price3 + price4; <br>
document.getElementById("LR2").innerHTML = <br>
"The total is: " + total; <br>
</script> <br>
答案 0 :(得分:0)
也许
$("#LR2").val() = 0
应该是:
$("#LR2").val() == 0
也不确定该值是否不是字符串...也许应该转换为数字:
Number( $("#LR2").val() ) == 0
答案 1 :(得分:0)
试试这个
var selectValue = 0;
if( $("#LR2").val() == 0) {
selectValue = 5;
}
else {
selectValue = 6;
}