Several basic jquery selectors
Mar 20, 2018 pm 04:59 PMThe basic selector is the most commonly used selector in jQuery and is also the simplest selector. It searches for DOM elements through element id, class and tag name.
id selector
id selector$('#id') matches an element by the given id, returning a single element
1 |
|
Corresponds to the getElementById() method of DOM, and jQuery also uses this method internally to handle the acquisition of ID
1 |
|
Element selector
Element selector$('element') is based on the given Matches elements with specified element names and returns qualified collection elements
1 2 3 4 |
|
corresponds to the getElementsByTagName() method of DOM, and jQuery also uses this method internally to handle the acquisition of element names
1 2 3 |
|
Class selector
Class selector$('.class') matches elements according to the given class name and returns qualified collection elements
1 2 3 4 |
|
corresponds to DOM’s getElementsByClassName() method, and jQuery also uses this method internally to handle the acquisition of class names
1 2 3 |
|
Wildcard selector
The wildcard selector $('*') matches all in the document element, and returns the collection element
1 |
|
corresponding to the document.all collection of the DOM
1 2 |
|
or the getElementsByTagName() method whose parameter is the wildcard *
1 2 |
|
group selection
Group selector $('selector1,selector2,...') merges the elements matched by each selector together, and returns the set element
1 2 3 4 |
|
corresponding to DOM's querySelectorAll( )Selector
1 2 3 |
|
The above is the detailed content of Several basic jquery selectors. For more information, please follow other related articles on the PHP Chinese website!

Hot tools Tags

Hot Article

Hot tools Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to use PUT request method in jQuery?

How to remove the height attribute of an element with jQuery?

jQuery Tips: Quickly modify the text of all a tags on the page

Use jQuery to modify the text content of all a tags

Understand the role and application scenarios of eq in jQuery

Summary of commonly used file operation functions in PHP

Master jQuery common event binding techniques

How to tell if a jQuery element has a specific attribute?
