02_jquery_02_ element Selector

Source: Internet
Author: User


The element selector is the element name to query the element

$ ("elementname") Here you can get the jquery element by the element name.

Unlike the ID selector, however, there are many elements with the same name, so many DOM elements are included in the JQuery object that gets to it.


<%@ Pagelanguage= "Java"Import= "java.util.*"pageencoding= "UTF-8"%><!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"><HTML>  <Head>    <title>Jquery Test</title>    <!--Importing jquery files -    <Scripttype= "Text/javascript"src= "${pagecontext.request.contextpath}/jquery-1.5.1.js"></Script>    <Scripttype= "Text/javascript">//The content here will execute a $ (function () { //element Selector when the document is loaded, find all DIV elements, it returns a JQuery object, but the jquery object contains multiple DOM                var ele=$ ("div");        alert (ele.length);    }); </Script>  </Head>    <Body>This is my JSP page.<BR>        <DivID= "id001"><P>Aaaaaa</P></Div>    <DivID= "id002">bbbbbb</Div>      </Body></HTML>

"Run Results"

02_jquery_02_ element Selector

Related Article

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.