Home > Web Front-end > JS Tutorial > What are the usages of javascript $

What are the usages of javascript $

coldplay.xixi
Release: 2021-03-31 16:43:16
Original
8650 people have browsed it

javascript $ usage: 1. [$()] can be [$(expresion)], that is, css selector, Xpath or html element; 2. [$()] can be [$(element) 】, that is, a specific DOM element.

What are the usages of javascript $

The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, DELL G3 computer.

javascript $ usage:

1. The meaning of $

The author of JS application library JQUERY uses $ as a Custom function name, this function is a function to obtain the specified web page element.

function $(Nid){
return document.getElementById(Nid);
}
Copy after login

2. Simple usage

Here are three simple usage methods.

2.1, $(expresion)

$() can be $(expresion), that is, css selector, Xpath or html element, that is, through the above expression to match the target element.

2.2. $(element)

$() can be $(element), which is a specific DOM element. For example, commonly used DOM objects include document, location, form, etc.

2.3. $(function)

$() can be $(function), that is, a function, which is a member of $(document).ready() shorthand.

$(document).ready(function(){ 
alert("Hello world!"); 
});
Copy after login

can write:

$(function(){ 
alert("Hello world!"); 
});
Copy after login

Related free learning recommendations: javascript video tutorial

The above is the detailed content of What are the usages of javascript $. 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