首页javascriptkeyJavascript Event - 如何通过ID获取元素并添加点击事件处理程序...

Javascript Event - 如何通过ID获取元素并添加点击事件处理程序...

我们想知道如何通过ID获取元素并添加点击事件处理程序。...


<html>
<head>
    <script language="JavaScript1.2">
    function showDialog(){
      console.log("A key was released");
    }
    </script>
</head>
<body>
    <form name="myForm">
       <textarea name="myTextArea" rows=2 cols=50 onKeyUp='showDialog()'>
       Here is some text in my text area.
       </textarea>
    </form>
</body>
</html>