jQuery官网: https://jquery.com/
参考文档: https://jquery.cuishifeng.cn/
jQuery库,里面封装大量JavaScript函数,相当于JavaScript的工具类
获取jQuery
方式一,通过cdn引入
https://www.bootcdn.cn/jquery/
https://cdn.baomitu.com/jquery
https://www.jq22.com/cdn/
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!-- cdn 引入 -->
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
</head>
<body>
</body>
</html>
方式二,下载后导入
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!-- cdn 引入 -->
<!-- <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>-->
<script src="lib/jquery-3.6.0.js"></script>
</head>
<body>
</body>
</html>
jQuery公式
公式:$(selector).action()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!-- cdn 引入 -->
<!-- <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>-->
<script src="lib/jquery-3.6.0.js"></script>
</head>
<body>
<a href="https://www.baidu.com/" id="test-jquery">点我</a>
<script>
// 选择器就是css的选择器
$('#test-jquery').click(function () {
alert('hello, jQuery')
})
// // js原始写法
// let test_id = document.getElementById('test-jquery')
// // test_id.click() // 点击这个按钮
// test_id.onclick = () => {
// alert('hello, jQuery')
// }
</script>
</body>
</html>
https://www.bilibili.com/video/BV1JJ41177di?p=26