jquery Get node name _jquery

Source: Internet
Author: User
Tags tag name tagname

The jquery Get (Index) method allows you to select an actual DOM element and manipulate it directly, rather than through the jquery function, and then directly access the TagName property of the DOM element. $ (this). Get (0) is equivalent to $ (this) [0].

such as the following elements

Copy Code code as follows:

<input id= "Test" type= "text" name= "xxx" value= "xxx" >
$ ("#test") [0].tagname

Get a DIV (note is uppercase)

How jquery Gets the name of an element, such as
Dd

$ ("#aa"). Xxxmethod get "div"
How jquery Gets the name of an element such as
Dd

$ ("#aa"). Xxxmethod get "div"

$ (' #elementId '). Get (0). tagName
$ ("#aa") [0].tagname it's okay.
JQuery get the sign signature

Copy Code code as follows:

$ (' #elementId '). Get (0). tagName

This gets the tag name in uppercase, such as: A, DIV

Background knowledge:

The transformation of jquery objects and Dom objects

Only jquery objects can use the method defined by jquery. Note that there is a difference between a DOM object and a jquery object, and the method is invoked with a DOM object or a jquery object in mind.
Ordinary DOM objects can generally be converted to jquery objects by $ ().
such as: $ (document.getelementbyidx_x ("MSG") is a jquery object, you can use the method of jquery.

Because the jquery object itself is a collection. So if the jquery object is to be converted to a DOM object, one of these items must be removed, which is generally accessible through the index.
such as: $ ("#msg") [0],$ ("div"). EQ (1) [0],$ ("div"). get () [1],$ ("TD") [5] These are DOM objects, you can use the methods in DOM, but you can no longer use the jquery method.

The following are the correct ways to do this:

Copy Code code as follows:

$ ("#msg"). html ();
$ ("#msg") [0].innerhtml;
$ ("#msg"). EQ (0) [0].innerhtml;
$ ("#msg"). Get (0). InnerHTML; -

The above mentioned is the entire content of this article, I hope you can enjoy.

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.