JQuery basic Selector

Source: Internet
Author: User

JQuery basic Selector
Selector

Description

Return

# Id

Matches an element based on the given id.

Single element

. Class

Matches the element based on the given class name.

Set Element

Element

Match an element based on the given element name

Set Element

*

Match All elements

Set Element

Selector1, selector2 ,...

Returns the elements matched by each selector together.

Set Element

Example:

[Javascript]
<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN"
Http://www.w3.org/TR/html4/loose.dtd>
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> New Web Project </title>
<Script type = "text/javascript" src = "jquery-core/jquery-1.8.0.js"> </script>
<Script type = "text/javascript">
$ (Function (){
$ ('# Bt1'). click (function (){
Alert ('Id selector: '{}('{d1'}.html ()
+ "\ Nclass selector:" commandid ('.c1'0000.html ()
+ "\ Nelement selector:" commandid ('p'%.eq(0%.html ()
+ "\ N * selector:" + $ ('* '{.eq(5}.html ()
+ "\ N multiple selector selected quantity:" + $ ('div, p, # bt1'). length
);
});
});



</Script>
</Head>
<Body>
<Div id = "d1"> I am a div </div>
<Div class = "c1"> I am a div2 </div>
<P> I am a p </p>
<Input type = "button" value = "button" id = "bt1"/>

</Body>
</Html>

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.