The different of the jquery get () eq ()

Source: Internet
Author: User

EQ Returns a JQuery object, and get returns an array of HTML objects. As an example:

<p style="color:yellow">绯雨</p>

Use EQ to get the color value of the first P tag:

$("p").eq(0).css("color")  //因为eq(num)返回的是个jq对象,所以可以用jq的方法css

Use get to get the color value of the first P tag:

$("p").get(0).style.color  //因为get(num)返回的是个html对象,所以要使用传统的HTML对象方法,jq对象此时就没用了。

Of course, you can also get (num) The object to the JQ object and then manipulate it:

$($("p").get(0)).css("color")
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.