<html>
<head>
<script>
function addEventsToHTML() {
var field1 = document.getElementById('field1');
var field2 = document.getElementById('field2');
field1.onkeypress = monitor;
field2.onkeypress = monitor;
function monitor() {
alert("key pressed in " + this.id);
}
}
window.onload = addEventsToHTML;
</script>
<title>test</title>
<body>
<input id="field1">
<input id="field2">
</body>
</html>
原文:
http://www.developphp.com/view_lesson.php?v=812
onkeypress
最新推荐文章于 2023-02-26 11:34:35 发布