Home > Article > Web Front-end > What is $ in JQuery?
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 "()".
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)就是 选取整个文档对象
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)")
2. Utility function, as the prefix of the namespace of several common utility functions
For example:
$.trim(someString)
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>")
5. Extend jQuery
For example:
$.fn.disable = function(){...}
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!