e.g. if i have this: <div id='mydiv'>whatever</div>
then let say in jQuery, how can I find out that the dom element with id "mydiv" is a DIV or is some other element type.
e.g. $('#mydiv').???? ?
The Element type represents an XML or HTML element, providing access to information such as its tag name, children, and attributes. the element's tag name. may be a Document or Element.
While browsers can handle larger DOM trees, they are optimized for a maximum of 32 elements deep. A large DOM tree can harm your page performance in multiple ways: Network efficiency and load performance.
Few people know about that. We are not going to touch that node, we even don't draw it on diagrams, but it's there. The document object that represents the whole document is, formally, a DOM node as well. There are 12 node types.
The easiest way to find an HTML element in the DOM, is by using the element id.
var type = $('#mydiv')[0].tagName alert(type); //displays "DIV"
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