Home >Web Front-end >Front-end Q&A >Is jquery a js function library?
jquery is a JavaScript function library; jquery is a lightweight, fast, and concise JavaScript library. jquery greatly simplifies JavaScript programming, encapsulates common JavaScript function codes, and provides a simple JavaScript Design mode, optimize HTML document operation, event handling, animation design and Ajax interaction.
The operating environment of this article: Windows 10 system, jquery version 3.6.0, Dell G3 computer.
jQuery is a fast and concise JavaScript library, which greatly simplifies JavaScript programming. The purpose of jQuery's design is "write less, do more", which means writing less code and doing more things. It encapsulates common JavaScript function codes, provides a simple JavaScript design pattern, and optimizes HTML document operations, event processing, animation design and Ajax interaction.
jQuery is a fast and concise JavaScript framework. It is another excellent JavaScript code library (or JavaScript framework) after Prototype. The purpose of jQuery's design is "write less, do more", which means writing less code and doing more things. It encapsulates common JavaScript function codes, provides a simple JavaScript design pattern, and optimizes HTML document operations, event processing, animation design and Ajax interaction.
The core features of jQuery can be summarized as follows: It has a unique chain syntax and a short and clear multi-functional interface; it has an efficient and flexible CSS selector, and can extend the CSS selector; it has convenient plug-in extensions Mechanism and rich plug-ins. jQuery is compatible with various mainstream browsers, such as IE 6.0, FF 1.5, Safari 2.0, Opera 9.0, etc.
Syntax and selectors
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
jquery entry function:
$(document).ready(function(){ // 执行代码 });
or
$(function(){ // 执行代码 });
selector
#id selector
Click the button to hide the selector with id test
$(document).ready(function(){ $("button").click(function(){ $("#test").hide(); }); });
.class selector
Click the button to hide the selector with class test
$(document).ready(function(){ $("button").click(function(){ $(".test").hide(); }); });
Event
$().click(function(){ …. })
For other events, please refer to the API at the end of the article
Get and set the css class
addClass() - Adds one or more classes to the selected element
removeClass() - Removes one or more classes from the selected element
toggleClass() - Add/delete class switching operation for selected elements
css()-Set or return style attributes
Example:
$(document).ready(function(){ $("button").click(function(){ $("body div:first").addClass("important blue"); }); }); .important { font-weight:bold; font-size:xx-large; } .blue { color:blue; }
Related tutorial recommendations: jQuery video tutorial
The above is the detailed content of Is jquery a js function library?. For more information, please follow other related articles on the PHP Chinese website!