Home >Web Front-end >Front-end Q&A >what is dollar sign in jquery
The dollar sign in jquery is an alias for jQuery, which represents the jQuery object; the basic syntax of jquery is "$(selector).action()", where the dollar sign $ defines jQuery, and selector represents the selector used for "Query" and "find" HTML elements, action() performs operations on elements.
The operating environment of this tutorial: Windows 10 system, jquery3.2.1 version, Dell G3 computer.
What is the dollar sign in jquery?
In jQuery, the dollar sign ($) is just an alias for jQuery, which represents a jQuery object. For example, $("div") and jQuery("div") are equivalent.
Note two points:
1. All functionality of jQuery can be guaranteed even without using $.
2. In order to avoid conflicts with other javascript libraries, you can release jQuery's control of the $ variable and specify a new custom name for the jQuery variable. For example:
After executing var jq=$.noConflict();, $ will no longer control the current jQuery, but will be transferred to the jq variable. At this time, jq("div") and jQuery(" div") are equivalent.
Related introduction:
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
elements
$("p.test").hide() - Hide all
elements with class="test"
$ ("#test").hide() - Hide elements with id="test"
Recommended learning: "jQuery Video Tutorial"
The above is the detailed content of what is dollar sign in jquery. For more information, please follow other related articles on the PHP Chinese website!