找不出錯(cuò)誤,但是不出結(jié)果
<!DOCTYPE html>
<html>
?<head>
? <title> 事件</title> ?
? <script type="text/javascript">
? ?function count(){
? ? var txt1=parselnt(document.getElementById("txt1").value); ??
? ? var txt2=parselnt(document.getElementById("txt2").value);
? ? var select=document.getElementById("select").value;
? ? var result;
? ? switch(select)
? ? {
? ? ? ? case'+':?
? ? ? ? ? ? result=txt1+txt2;
? ? ? ? ? ? break;
? ? ? ? case'-':?
? ? ? ? ? ? result=txt1-txt2;
? ? ? ? ? ? break;
? ? ? ? case'*':?
? ? ? ? ? ? result=txt1*txt2;
? ? ? ? ? ? break;
? ? ? ? case'/':?
? ? ? ? ? ? result=txt1/txt2;
? ? ? ? ? ? break;
? ? }
? ? document.getElementById("fruit").value=result;
? ?}
? </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()"/>
? ?<input type='text' id='fruit' /> ??
?</body>
</html>
2016-08-14
parseInt? 駝峰命名? 這個(gè)是全局函數(shù) ,區(qū)分大小寫
2016-08-15
記得加上<meta charset="utf-8" />,不然title的中文顯示不了,parseInt都能打錯(cuò),基礎(chǔ)知識(shí)還不夠
2016-08-15
parseInt中的I是i的大寫字母,不是L的小寫,整數(shù)類型Int;
2016-08-15
parseInt,中間十大寫的I不是小寫的L