初识
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
</head>
<a href="#" id="test-jquery">点我</a>
<body>
<script>
$('#test-jquery').click(function (){
alert('jquery被点了')
})
</script>
</body>
</html>
事件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
<style>
#movediv{
width: 600px;
height: 600px;
border: 1px solid hotpink;
}
</style>
</head>
<body>
鼠标:<span id="mousemove"></span>
<div id="movediv">
在这里移动鼠标
</div>
<script>
$(function (){
$('#movediv').mousemove(function (e){
$('#mousemove').text('x:'+e.pageX + 'y:'+e.pageY)
})
});
</script>
</body>
</html>