Black Horse DAY16 jquery basic Selector

Source: Internet
Author: User

The basic selector is the most commonly used selector in jquery and the simplest selector, which finds DOM elements through element Id,class and tag names (only once in a Web page, and class allows for reuse).

1,#idusage: $ ("#myDiv"); returns a collection of values that comprise a single element

Description: This is the direct selection of HTML in the id= "Mydiv"

2,Elementusage: $ ("div")return value Collection element

Note: The English translation of element is "elemental", so element is actually a tag element that is already defined in HTML, such as Div,input, A, and so on.

3,classusage: $ (". MyClass")return value Collection element

Note: This tag is a direct selection of elements or groups of elements in the HTML code that class= "MyClass" (because class can have more than one value in the same HTML page).

4, * usage:$ ("*")return value Collection element

Description: Matches all elements and is used in conjunction with context to search

5,Selector1, Selector2, Selectornusage:$ ("Div,span,p.myclass")return value Collection element

Description: Merges the elements that match each selector to return together. You can specify any number of selectors and merge the matched elements into one result. Where p.myclass is a matching element

Pclass= "MyClass"

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Black Horse DAY16 jquery basic Selector

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.