Home >Web Front-end >Front-end Q&A >what is dollar sign in jquery

what is dollar sign in jquery

藏色散人
藏色散人Original
2023-02-17 10:32:362212browse

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.

what is dollar sign in jquery

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!

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