JQuery-based code for obtaining tag names

Source: Internet
Author: User
Here, you can obtain the tag name in uppercase, for example, A, DIV. If you need the tag name, refer to jquery to obtain the name of an element. For example:

Dd


$ ("# Aa"). xxxmethod returns to "p"

How does jquery obtain the name of an element, such

Dd


$ ("# Aa"). xxxmethod to get "p"


[Kunming] Si Xue Chuan Qiong (447031499) 13:35:50
$ ('# Elementid'). get (0). tagName
$ ("# Aa") [0]. tagName.

JQuery obtains the Tag Name

The Code is as follows:


$ ('# Elementid'). get (0). tagName


Here, the tag name is capitalized, for example, A, DIV.

Background:

Conversion between jQuery objects and dom objects
Only jquery objects can use methods defined by jquery. Pay attention to the differences between dom objects and jquery objects. When calling methods, pay attention to dom objects or jquery objects.
Common dom objects can be converted to jquery objects through $.
For example, $ (document. getElementById ("msg") is a jquery object. You can use the jquery method.
Because the jquery object itself is a set. Therefore, if a jquery object is to be converted to a dom object, You must retrieve one of them. Generally, you can retrieve it through indexes.
For example: $ ("# msg") [0], $ ("p "). eq (1) [0], $ ("p "). get () [1], $ ("td") [5] are all dom objects. You can use methods in the dom, but you cannot use Jquery methods.
The following statements are correct:
$ ("# Msg" cmd.html ();
$ ("# Msg") [0]. innerHTML;
$ ("# Msg"). eq (0) [0]. innerHTML;
$ ("# Msg"). get (0). innerHTML;
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.