<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type="text/css">
body {
font-size: 13px;
}
.clsTip {
border: 1px solid #CCCCCC;
background-color: #EEEEEE;
margin-top: 15px;
padding: 5px;
width: 185px;
display: none;
}
.txt {
border: 1px solid #666666;
padding: 3px;
}
</style>
<script src="../js/jquery-3.5.1.js"></script>
<script>
$(function () {
$(".txt").bind({focus:function () {
$("#divTip").show("normal").html("执行focus事件");
},
change:function () {
$("#divTip").show("normal").html("执行change事件");
}});
});
</script>
</head>
<body>
<div>姓名:<input type="text" class="txt"></div>
<div id="divTip" class="clsTip"></div>
</body>
</html>