Use of jquery selectors 1---get HTML and properties

Source: Internet
Author: User

1. Get HTML content

Find all spans of class Class1, and then get the HTML value

a=$ ('. Class1 '). Find (' span ')

Console.log (a.html ())


Find the first element of class Class1, and then get the HTML value

a=$ ('. Class1 '). EQ (0)

Console.log (a.html ())

2. Get the attributes of an element


$ ('. Entry-name '). Find (' a ') [0].href

$ ("a"). EQ (0) [0].href


To add an index to the main property

Because $ ('. Entry-name '). Find (' a ') or $ ("a"). EQ (0)

The result is a number of groups:

[<a class= "Navbar-brand" href= "#" > Operation and Maintenance Management system </A>]


This article from "Select" blog, declined reprint!

Use of jquery selectors 1---get HTML and properties

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.