點(diǎn)擊事件為什么沒發(fā)生呢
window.onload=function(){
? ? ? var oBtn=document.getElementById('btn');
? ? ? var oTxt1=parseFloat(document.getElementById('txt1').value);
? ? ? var oTxt2=parseFloat(document.getElementById('txt2').value);
? ? ? var oTxt3=document.getElementById('fruit').value;
? ? ? var oSel=document.getElementById('select').value;
? ? ? var oTxt3='';
? ? ??
? ? ? ? function count(){
? ?
? ? ? ? ? ? switch(oSel){
? ? ? ? ? ? ? ? ?case "+":
? ? ? ? ? ? ? ? ? oTxt3=oTxt1+oTxt2;
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ?case "-":
? ? ? ? ? ? ? ? oTxt3=oTxt1-oTxt2;
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? case "*":
? ? ? ? ? ? ? ? oTxt3=oTxt1*oTxt2;
? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? case "/":
? ? ? ? ? ? ? oTxt3=oTxt1/oTxt2;
? ? ? ? ? ? ? ?break;
? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ?}
? ? ? ? ?
? ? ? ? }
? ? ? oBtn.onclick=function(){
? ? ? count();
? ? ? };
? ? ?};?
2017-04-15
發(fā)生了,但是你的count()方法里既沒有在控制臺(tái)打印語句,也沒有在瀏覽器輸出東西,所以你察覺不到點(diǎn)擊事件的執(zhí)行