jQuery_ introduction and installation

What is jQuery

  • jQuery Is a front-end library, but also a method library
  • He encapsulates a series of methods for us to use
  • Some of our commonly used methods are in it, we can just use it directly

What can jQuery do

  • jQuery The reason why it is easy to use is that many people are willing to use it because several of its advantages are too powerful.
  1. Quality selectors and filters
  2. Useful implicit iteration
  3. Powerful chain programming
  • Because of the emergence of these things, many times what we have to do is "solved by one line of code"

jQuery compatibility

  • jquery does not need to consider compatibility at all, because the jquery library encapsulates the compatibility of js
  • Only when the major version is 1. It can be compatible to ie8 and below

jQuery frequently used websites

jQuery installation tutorial

  1. Open jQuery official website
    Insert picture description here
  2. Click on the download page

Insert picture description here

jQuery release notes

  • Production version -Used in the actual website, it has been streamlined and compressed.
  • Development version -For testing and development (uncompressed, readable code)

How to use jQuery

Introduction method

  1. Use the downloaded library file directly
<head>
	<script src="./js/jquery-3.5.1.js"></script>
</head>
  1. Load jQuery from CDN
<head>
	// 百度压缩版引用地址:
	<script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js"></script>
	// 微软压缩版引用地址:
	<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.5.0.min.js"></script>
	// cdnjs压缩版引用地址:
	<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>

Check whether the introduction is successful

  • Allow code:
// 下面两个代码都是可以的,用其中一个就行
alert($) // 弹出一个函数就说明引入成功
alert(jQuery)	// $ 等同于 jQuery
  • Pop up successfully (just a function, not exactly the same):
    Insert picture description here

Guess you like

Origin blog.csdn.net/qq_45677671/article/details/114294397