我有要求不使用html事件处理程序。所以我试图从脚本中处理它。我做了一个小功能,但它不起作用onkeypress事件监听器不工作
<head>
<script type="text/javascript">
function lld() {
document.getElementById('me').onkeypress= myfunction()
}
function myfunction(){
alert('hiiiii')
}
</script>
</head>
<body>
<input type="text" id="me" />
</body>
</html>
为什么否决了,我才问了什么。我只是把这个问题放在我面前 – Carlos
你的意思是你需要避免INLINE事件处理程序 – mplungjan
是的。但是我在这里谈论投票下来 – Carlos