Home > Web Front-end > JS Tutorial > What does $ in jquery mean?

What does $ in jquery mean?

coldplay.xixi
Release: 2020-11-16 15:12:33
Original
18047 people have browsed it

The $ of jquery is another name for jQuery, [$(document)] is to select the entire document object, [$] is the jquery object, [$()] is [jQuery()], in which parameters can be passed , its function is to obtain elements.

What does $ in jquery mean?

Recommended: "jquery video tutorial"

<strong>$</strong> is another name for jQuery

And jQuery is a function provided by the jQuery library. (It seems that it is not just a function, because there is also the use of $.ajax(options), which is equivalent to jQuery.ajax(options))

The function of this function is to search and select elements in the html document based on the parameters in (). One of the functions of the function is to replace GetElementByID, but () It can be not only ID, but also various selectors

For example:

$(document)It is to select the entire document object

That is It's not just $ that can be used instead, no. To prevent naming conflicts, the jQuery library provides additional mechanisms to give jQuery functions additional aliases.

For example:

var jq = jQuery.noConflict();
// Do something with jQuery
j("div p").hide();
// Do something with another library&#39;s $()
$("content").style.display = &#39;none&#39;;
Copy after login

You can use jq instead of jQuery and $ in the code.

Let’s take a look at the difference between using $. and $(). in jquery. What are their respective meanings?

$ is the jquery object, $() is jQuery(), you can pass parameters in it, and its function is to get the element

The following example

$(".div1") 表示获取类名为div1的元素,例如获取<div class="div1"></div>
$(".div1").onclick表示类名为div1的div点击事件
jquery中$.,例如$.post(),$.get(),$.ajax()等这些都是jquery这个对象的方法
Copy after login

Related free learning recommendations: JavaScript (video)

The above is the detailed content of What does $ in jquery mean?. 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