如何添加DOM 0级事件
<script type="text/javascript"> function count(){ var txt1 = parseFloat(document.getElementById("txt1").value); var txt2 = parseFloat(document.getElementById("txt2").value); var select = document.getElementById("select").value; var s switch(select) { case "+": s=txt1+txt2; break; case "-": s=txt1-txt2; break; case "*": s=txt1*txt2; break; case "/": s=txt1/txt2; break; } document.getElementById("fruit").value = s; } var btn = document.getElementById("btn").value; btn.onclick = count; </script>
在这里应该如何给按钮添加DOM 0级事件