Is there a jQuery function that tells you the tag name of a given element?
Say I have an element that represents a <tr>
. What function do I need to call to get "tr"
?
I need this for debugging. Thanks.
get tag name using jquery and javascript 1 Get Element and ID, if any on mouseover with jQuery -1 JQuery - Find out what HTML Tag is $(this) 0 click element html, Show type html tags to text
The #id Selector. The jQuery #id selector uses the id attribute of an HTML tag to find the specific element. An id should be unique within a page, so you should use the #id selector when you want to find a single, unique element. To find an element with a specific id, write a hash character, followed by the id of the HTML element: $("#test")
Select an element that has a class name of “class”, and use the .get (0).tagName function to get this tag name. Select an element that has a class name of “class”, and use the . [0].tagName function to get this tag name. It will help you....
All selectors in jQuery start with the dollar sign and parentheses: $ (). The jQuery element selector selects elements based on the element name. You can select all <p> elements on a page like this:
It should be quite easy, just use the .get()
method:
nativeElement.tagName;
or
jQueryElement.get(0).tagName;
Or for all cases:
$(element).get(0).tagName;
If you have a <tr>
element, do:
var tagName = tr.tagName.toLowerCase();
If your <tr>
element is wrapped in a jQuery object, do:
var tagName = tr.get(0).tagName.toLowerCase();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With