<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.parent {
/* width: 100px;
height: 100px;
background: red; */
}
</style>
</head>
<body>
<input type="number" class="parent" onclick="add()" value="1">
<script>
function add() {
alert('cdfcvfdy');
}
document.onkeydown = function(event) {
var e = event || window.event;
if (e && e.keyCode == 13) {
add();
}
}
</script>
</body>
</html>
键盘enter事件
最新推荐文章于 2023-11-25 23:13:19 发布