"; 2. Use the script tag to import online. jquery file, syntax ""."/> "; 2. Use the script tag to import online. jquery file, syntax "".">
search
HomeWeb Front-endFront-end Q&AWhich file does jquery need to import?

Which file does jquery need to import?

Jan 03, 2023 pm 07:31 PM
javascriptjquery

You need to import the jquery.js file before using jquery. Two import methods: 1. Download the jquery file locally from the jquery official website, and use the script tag to import the local jquery file. The syntax is ""; 2. Use script The tag imports the online jquery file with the syntax "".

Which file does jquery need to import?

The operating environment of this tutorial: windows7 system, jquery3.6 version, Dell G3 computer.

1. Introduction to jQuery

  • ##jQuery is a js library that stores function() written in js code .

  • The original intention of jQuery is to simplify JS code.

  • Can handle HTML/JSP/XML, CSS, DOM, events, and also provide asynchronous AJAX functionality.

  • For example:

    document.getElementByid() Encapsulates a method in jQuery:

  • function $("#id"){//函数名是$
    	return document.getElementById(id);
    }

2. Use:

jQuery is actually a js file. When we use it, we first need to introduce the file into the HTML document. There are two ways to import jquery, one is local import and the other is import from hyperlink.

Introduction method one: local introduction

We can search jquery on Baidu and find the official website of jquery: https://jquery.com/

You can download the latest version of jquery from here. Click the download icon and you will jump to the download details page:

Which file does jquery need to import?

The first two links here are for two versions. jquery download, one is a compressed version and the other is an uncompressed version. There is no functional difference between the two versions. It is just that the compressed version has been deleted in order to take up less space for jquery when publishing the project. Extra spaces and line breaks are used to achieve the purpose of streamlining. As developers, we have not yet reached the stage of publishing the project, so we just choose the second uncompressed version.

Click on the link and you can see the source code of 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 ></script>
<script>
	//在此书写你的jquery代码
</script>

Which file does jquery need to import?

Which file does jquery need to import?

Note ! 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.

Introduction method two: introduce online jquery

We can import the online jquery code by writing a URL in the src attribute of the script. Someone may want to ask, Wouldn't this cause a delay in downloading jquery when the web page is loading? Will it take a long time to download, causing your jquery code to never be loaded, affecting the user experience?

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.

For example, the online JQ file of jquery official website: https://code.jquery.com/jquery-3.6.0.min.js

Which file does jquery need to import?

Import online jquery:

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
	//在此书写你的jquery代码
</script>

Usage:

Create jQuery objects to call functions in the library

[Recommended learning:

jQuery video tutorialwebfront-end video

The above is the detailed content of Which file does jquery need to import?. For more information, please follow other related articles on the PHP Chinese website!

Statement
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
The Size of React's Ecosystem: Navigating a Complex LandscapeThe Size of React's Ecosystem: Navigating a Complex LandscapeApr 28, 2025 am 12:21 AM

TonavigateReact'scomplexecosystemeffectively,understandthetoolsandlibraries,recognizetheirstrengthsandweaknesses,andintegratethemtoenhancedevelopment.StartwithcoreReactconceptsanduseState,thengraduallyintroducemorecomplexsolutionslikeReduxorMobXasnee

How React Uses Keys to Identify List Items EfficientlyHow React Uses Keys to Identify List Items EfficientlyApr 28, 2025 am 12:20 AM

Reactuseskeystoefficientlyidentifylistitemsbyprovidingastableidentitytoeachelement.1)KeysallowReacttotrackchangesinlistswithoutre-renderingtheentirelist.2)Chooseuniqueandstablekeys,avoidingarrayindices.3)Correctkeyusagesignificantlyimprovesperformanc

Debugging Key-Related Issues in React: Identifying and Resolving ProblemsDebugging Key-Related Issues in React: Identifying and Resolving ProblemsApr 28, 2025 am 12:17 AM

KeysinReactarecrucialforoptimizingtherenderingprocessandmanagingdynamiclistseffectively.Tospotandfixkey-relatedissues:1)Adduniquekeystolistitemstoavoidwarningsandperformanceissues,2)Useuniqueidentifiersfromdatainsteadofindicesforstablekeys,3)Ensureke

React's One-Way Data Binding: Ensuring Predictable Data FlowReact's One-Way Data Binding: Ensuring Predictable Data FlowApr 28, 2025 am 12:05 AM

React's one-way data binding ensures that data flows from the parent component to the child component. 1) The data flows to a single, and the changes in the state of the parent component can be passed to the child component, but the child component cannot directly affect the state of the parent component. 2) This method improves the predictability of data flows and simplifies debugging and testing. 3) By using controlled components and context, user interaction and inter-component communication can be handled while maintaining a one-way data stream.

Best Practices for Choosing and Managing Keys in React ComponentsBest Practices for Choosing and Managing Keys in React ComponentsApr 28, 2025 am 12:01 AM

KeysinReactarecrucialforefficientDOMupdatesandreconciliation.1)Choosestable,unique,andmeaningfulkeys,likeitemIDs.2)Fornestedlists,useuniquekeysateachlevel.3)Avoidusingarrayindicesorgeneratingkeysdynamicallytopreventperformanceissues.

Optimizing Performance with useState() in React ApplicationsOptimizing Performance with useState() in React ApplicationsApr 27, 2025 am 12:22 AM

useState()iscrucialforoptimizingReactappperformanceduetoitsimpactonre-rendersandupdates.Tooptimize:1)UseuseCallbacktomemoizefunctionsandpreventunnecessaryre-renders.2)EmployuseMemoforcachingexpensivecomputations.3)Breakstateintosmallervariablesformor

Sharing State Between Components Using Context and useState()Sharing State Between Components Using Context and useState()Apr 27, 2025 am 12:19 AM

Use Context and useState to share states because they simplify state management in large React applications. 1) Reduce propdrilling, 2) The code is clearer, 3) It is easier to manage global state. However, pay attention to performance overhead and debugging complexity. The rational use of Context and optimization technology can improve the efficiency and maintainability of the application.

The Impact of Incorrect Keys on React's Virtual DOM UpdatesThe Impact of Incorrect Keys on React's Virtual DOM UpdatesApr 27, 2025 am 12:19 AM

Using incorrect keys can cause performance issues and unexpected behavior in React applications. 1) The key is a unique identifier of the list item, helping React update the virtual DOM efficiently. 2) Using the same or non-unique key will cause list items to be reordered and component states to be lost. 3) Using stable and unique identifiers as keys can optimize performance and avoid full re-rendering. 4) Use tools such as ESLint to verify the correctness of the key. Proper use of keys ensures efficient and reliable React applications.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),