Home >Web Front-end >JS Tutorial >jQuery framework overview

jQuery framework overview

善始善终
善始善终Original
2020-08-26 22:16:55279browse

1. jQuery is a JavaScript function library. jQuery is a lightweight "write less, do more" JavaScript library. The jQuery library contains the following functions:

  • HTML element selection

  • HTML element manipulation

  • CSS manipulation

  • HTML event function

  • JavaScript special effects and animation

  • HTML DOM traversal and modification

  • AJAX

  • Utilities

##2.jQury Advantages

Lightweight, Powerful selector, excellent DOM operation encapsulation, reliable event processing mechanism, perfect Ajax, no pollution of top-level variables, excellent browser compatibility, chain operation mode, implicit iteration, separation of behavior layer and structure layer , Rich plug-in support:, complete documentation, open source.

3. There are many ways to add jQuery to a web page. You can use the following methods:

  • Download jQuery library from jquery.com

  • Load jQuery from CDN, such as loading jQuery from Google

4. Download jQuery from the official website

(1) Enter the official website (https://jquery.com/download/)

(2) Single Click the "Download jQuery" button to enter the download page

(3) There are two versions of jQuery available for download:

  • Production version - used in actual websites, Has been streamlined and compressed.

  • Development version - for testing and development (uncompressed, readable code)

(4) The jQuery library is a JavaScript file, you can reference it using the HTML 3f1c4e4b6b16bbbd69b2ee476dc4f83a tag.

5. CDN configuration jQUery

If you do not want to download and store jQuery, you can also reference it through a CDN (Content Delivery Network). Staticfile CDN, Baidu, Youpaiyun, Sina, Google and Microsoft all have jQuery on their servers. If your site users are domestic, it is recommended to use domestic CDN addresses such as Baidu, Youpaiyun, Sina, etc. If your site users are foreign, you can use Google and Microsoft. For example, if you want to use Baidu's CDN, you can use the following method:

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

6. jQuery syntax

jQuery syntax is to select HTML elements and perform certain operations on the selected elements.

Basic syntax: $(selector).action()

  • Dollar sign definition jQuery

  • Selector (selector) "Query" and "Find" HTML elements

  • jQuery's action() performs operations on elements

Example:

  • $(this).hide() - Hide the current element

  • $("p").hide() - Hide all e388a4556c0f65e1904146cc1a846bee elements

  • $("p.test").hide() - Hide all e388a4556c0f65e1904146cc1a846bee elements

  • $("#test" ).hide() - Hide the element with id="test"

7. jQuery entry function

$(document).ready(function(){

// Start writing jQuery code...

});

Abbreviation mode:

$(function(){

/ / Start writing jQuery code...

});

The above is the detailed content of jQuery framework overview. 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