沒有輸出哪錯了?
<!DOCTYPE html>
<html>
?<head>
? <title> 事件</title>??
? <script type="text/javascript">
? ?function count(){
? ? ?var shu1=document.getElementById("txt1").value;
var shu2=document.getElementById("txt2").value;
? ? ?var fh=document.getElementById("select").value;
? ? ?var jieguo="";
? ? ?switch(fh){
? ? ? case "+" :
? ? ? ? ? jieguo=parseInt(shu1)+parseInt(shu2);
? ? ? ? ? break;
? ? ? case "-" :
? ? ? ? ? ?jieguo=parseInt(shu1)-parseInt(shu2);
? ? ? ? ? break;
? ? ? case "*" :
? ? ? ? ? ?jieguo=parseInt(shu1)*parseInt(shu2);
? ? ? ? ? break;
? ? ? default:
? ? ? ? ? ? jieguo = parseFloat(shu1) / parseFloat(shu2);
? ? ??
? }
? ? document.getElementById("fruit").value = jieguo;
? ?}
? </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=' = ' onlick="count()"/>?
? ?<input type='text' id='fruit' />? ?
?</body>
</html>
2020-02-08
onclick,你拼錯了