<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<p><input type="text" id="username"></p>
<script src="./jquery.js"></script>
<script>
// $('#username').on('keydown', function(event) {
// console.log(event.type)
// })
// $('#username').on('keypress', function(event) {
// console.log(event.type)
// })
// $('#username').on('keyup', function(event) {
// console.log(event.type)
// })
// jQ 考虑到键盘事件经常要使用,因此为我们提供了一些简便方法
$('#username').keydown(function(event) {
console.log(event.type)
}).keypress(function(event) {
console.log(event.type)
}).keyup(function(event) {
console.log(event.type)
})
</script>
</body>
</html>
jQuey---键盘事件
最新推荐文章于 2022-01-08 08:53:52 发布