【笔记】jQuery介绍与使用

简单介绍jQuery:

jQuery 是一个 JavaScript 库。

jQuery 极大地简化了 JavaScript 编程。

jQuery 很容易学习。

安装jQuery:

进入jQuery官网,下载jQuery库,然后在html页面中引用。例如:

<head>
<script src="jquery-3.3.1.js"></script>
</head> 

另外,jquery.js文件无压缩,用于测试和学习;jquery.min.js文件已压缩,用于实际的网站。

使用CDN引用:

 如果不想下载jQuery文件,可以使用这些CDN,

谷歌CDN:

<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>

微软CDN:

<head>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.3.1.js"></script>
</head>

百度CDN:

<head>
<script src="https://apps.bdimg.com/libs/jquery/3.3.1/jquery.min.js"></script>
</head>

官方:

<head>
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
</head>

等等......

用户访问其他网站时可能已经加载过jQuery,在访问您的页面是会从缓存中加载jQuery,提高加载速度。

猜你喜欢

转载自www.cnblogs.com/yj920/p/10046300.html