Home > Web Front-end > JS Tutorial > body text

How to introduce jquery?

little bottle
Release: 2019-10-09 14:50:04
Original
40042 people have browsed it

jquery is a library used to quickly write front-end scripting language instead of JavaScript. jquery can greatly simplify complex js code, allowing developers to focus on achieving the effect of the page.

How to introduce jquery?

Import method

There are two ways to import jquery, one is to import locally and the other is to import from Hyperlink import.

Related topic recommendations: "jQuery Tutorial"

Method 1: Local import

We can search jquery on Baidu, you can Search the official website of jquery:

https://jquery.com/

From here you can download the latest version of jquery. Click the download icon and it will jump to the download details page.

How to introduce jquery?

Click on the link and you can see the source code of jquery, as follows.

How to introduce jquery?

We directly ctrl a, select all, create a new txt file, copy the source code into it, and then change the suffix to .js.

Next, we introduce this .js file into the page where we want to use jquery. The code is as follows:

<script src="你的.js文件路径"></script>
<script>
	//在此书写你的jquery代码
</script>
Copy after login

Attention

Attention! Be sure to write the imported script first and then your own jquery code, because the loading order of the page is from top to bottom. The browser will load your jquery code first and then the jquery library, causing your jquery code to be considered an error. The writing format cannot achieve the effect.

Method 2: Import online jquery

We can import the online jquery code by writing a URL in the src attribute of the script.

In fact, there are many websites that use jquery now. The browser will pre-download jquery when loading the website that used jquery before, so we don’t need to download it again, even if our jquery version is It is a new version that has not been loaded by the browser, and the jquery code will be downloaded very quickly. However, if you are still worried about affecting the loading speed, importing the jquery file locally is indeed the best way.

Import online jquery:

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
	//在此书写你的jquery代码
</script>
Copy after login

The above is the detailed content of How to introduce jquery?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!