求解釋 大神
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title> ?
? <script type="text/javascript">
?? function count(){
?? ??? ?var txt1?? = parseInt( document.getElementById('txt1').value);//獲取第一個輸入框的值
?? ??? ?var txt2?? = parseInt( 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-12-18
var result;是指提前聲明result.
2016-12-18
我這里把var result = '';//這里什么意思????????????怎么解釋??注釋掉就可以了。Firefox瀏覽器。