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

What is $ in JQuery?

青灯夜游
Release: 2023-01-28 15:30:24
Original
11277 people have browsed it

In JQuery, "$" is the alias of jQuery. It is a callback function provided by the jQuery library. It is defined as "select" and is the abbreviation of "selector"; the syntax "$(selector)" has the function It searches and selects elements in the HTML document based on the parameters in "()".

What is $ in JQuery?

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

What does "$" in jquery mean?

$ is a commonly used return function in JQuery, which is defined as "select". In English, it is the abbreviation of selector.

$ is actually another name for jQuery, and jQuery is provided by the jQuery library. a function.

This function can search and select elements in the html document based on the parameters in (). () can not only be IDs, but also various selectors

For example:

$(document)就是 选取整个文档对象
Copy after login

The role of jquery $ symbol

1. As a jQuery wrapper, use the selector to select DOM elements (this is also the most powerful function)

For example:

$("table tr:nth-child(even)")
Copy after login

2. Utility function, as the prefix of the namespace of several common utility functions

For example:

$.trim(someString)
Copy after login

3. Document ready handler , equivalent to $(document).ready(...)

For example: $(function(){...}); The function inside will be executed after the DOM tree is loaded

4. Create DOM elements

For example:

$("<p>how are you?</p>")
Copy after login

5. Extend jQuery

For example:

$.fn.disable = function(){...}
Copy after login

6. Use jQuery and other libraries

For example: the Prototype library also uses the $ symbol. jQuery provides the noConflict function to avoid conflicts. jQuery.noConflict(); restores the $ symbol to the meaning defined by the non-jQuery library.

[Related recommendations: jQuery video tutorial]

The above is the detailed content of What is $ in 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template