不知道為什么就是不能運行 感覺沒什么問題了
<!DOCTYPE html>
<html>
?<head>
? <title> 事件</title> ?
? <script type="text/javascript">
? ?function count(){
? ? ? ?
? ? ?var x=document.getElementById("txt1").value;
? ? ?var y=document.getElementById("txt2").value; ?
var op=document.getElementById("select").value;?
? ? ?
switch(op)
? ? case "+":?
? ? ? ? ? ? document.getElementById("fruit").value=parselnt(x)+parselnt(y);
? ? ? ? ? ? break;
? ? case "-":
? ? ? ? ? ? document.getElementById("fruit").value=parselnt(x)-parselnt(y);
? ? ? ? ? ? break;
? ? case "*":
? ? ? ? ? ? document.getElementById("fruit").value=parselnt(x)*parselnt(y);
? ? ? ? ? ? break;
? ? case "/":
? ? ? ? ? ? document.getElementById("fruit").value=parselnt(x)/parselnt(y);
? ? ? ? ? ? break;
? ?}
? </script>?
?</head>?
?<body>
? ?<input type='text' id='txt1' >?
? ?<select id='select'>
<option value='+'>+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
? ?</select>
? ?<input type='text' id='txt2'>?
? ?<input type='button' value=' count ' onclick="count()"> <!--通過 = 按鈕來調(diào)用創(chuàng)建的函數(shù),得到結(jié)果-->?
? ?<input type='text' id='fruit' > ??
?</body>
</html>
2016-06-25
有可能是其他原因,代碼是可以運行
2016-06-25
運算符與值之間最好隔一個空格
2016-06-23
連加減都不能運行