這個(gè)代碼為啥不靈呢,好奇怪,是哪錯(cuò)了,望高手指導(dǎo),謝謝!
<!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 sel=document.getElementById("select").value;
var fur=0;
switch(sel)
{case"+";
? ?fur=parseInt(x)+parseInt(y);
? ?break;
? ?case"-";
? ?fur=parseInt(x)-parseInt(y);
? ?break;
? ?case="*";
? ?fur=parseInt(x)*parseInt(y);
? ?break;
? ?case="/";
? ?fur=parseInt(x)/parseInt(y);
? ?break;
}
? ? ? document.getElementById("fruit").value =fur;??
? ?}
? ?
? </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=' = ' onclick="count()" /> <!--通過(guò) = 按鈕來(lái)調(diào)用創(chuàng)建的函數(shù),得到結(jié)果-->?
? ?<input type='text' id='fruit' />? ?
?</body>
</html>
2020-07-18
兄die,你這個(gè)改改哈
把標(biāo)點(diǎn)改成:
把不必要的等號(hào)去掉
應(yīng)該就pass了
2020-07-20
多謝指點(diǎn),謝謝