<!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>
第一个问题 想问一下 为什么var select = document.getElementById('select').value;一定要后面有.value; 代表什么意思?
第二个问题我在w3c那个网站里面看了一下关于select这个标签 没有找到它有value这个属性 请问是因为w3c并不是所有属性都会罗列出来的关系嘛?
谢谢!
荼酒
相关分类