<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<script>
i=0;
$(document).ready(function(){
$("input").keypress(function(event){
console.log(event);
$("span").text(event);
});
});
</script>
</head>
<body>
输入你的名字: <input type="text">
<p>按键的次数: <span>0</span></p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<script>
i=0;
$(document).ready(function(){
$("#a").on("click",function(event){
console.log(event);
$("span").text(event);
});
});
</script>
</head>
<body>
输入你的名字: <input type="text">
<p>按键的次数: <span>0</span></p>
<button id="a" val ="b">按钮</button>
</body>
</html>
event.toElement.attributes.val.value
<script>
i=0;
$(document).ready(function(){
$("#a").on("click",function(event){
console.log(event);
$("span").text(event.toElement.attributes.val.value);
});
});
</script>