為什么case值與select值不匹配,計算也能成功?
?<script type="text/javascript">
? ?function count(){
? ? var x=document.getElementById("txt1").value
? ? var y=document.getElementById("txt2").value
? ? var z=document.getElementById("select").value
? ? var s=document.getElementById("fruit").value;
? ? switch(z)
? ? {
? ? case 1;
? ? s=parseInt(x)+parseInt(y);
? ? break;
? ? caee 2;
? ? s=parseInt(x)-parseInt(y);
? ? break;
? ? case 3;
? ? s=parseInt(x)*parseInt(y);
? ? break;
? ? default;
? ? s=parseInt(x)/parseInt(y);
? ? }
??
? ?}
? </script>?
?</head>?
?<body>
? ?<input type='text' id='txt1' />?
? ?<select id='select'>
? ? <option value='+'>+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
? ?</select>
為什么case值與select值不匹配,計算也能成功?
2016-05-20
? default;
? ? s=parseInt(x)/parseInt(y);
會運算這個
2016-05-13
代碼不完整
2016-05-13
提問首先要確保代碼正確吧。。。這個代碼你確定正確么