Copy Code code as follows:
$ ("DD"). Bind ("click", Function (e) {
var $obj = $ (e.target);
var i=0;
for (var x in $obj) {
i++;
var $hr = (i%5==0)? "document.write (x+ "" + $hr);
}
});
Traversal results:
0 Length Prevobject Context Selector
--------------------------------------------------------------------------------
Constructor init jquery size ToArray
--------------------------------------------------------------------------------
Get pushstack all ready eq
--------------------------------------------------------------------------------
The Slice map end
--------------------------------------------------------------------------------
Push sort Splice Extend data
--------------------------------------------------------------------------------
Removedata Queue dequeue Delay Clearqueue
--------------------------------------------------------------------------------
Promise attr Removeattr Prop Removeprop
--------------------------------------------------------------------------------
AddClass Removeclass Toggleclass Hasclass val
--------------------------------------------------------------------------------
Bind one Unbind delegate undelegate
--------------------------------------------------------------------------------
Trigger Triggerhandler Toggle Hover Live
--------------------------------------------------------------------------------
Die Blur Focus Focusin Focusout
--------------------------------------------------------------------------------
Load Resize Scroll Unload click
--------------------------------------------------------------------------------
DblClick MouseDown MouseUp MouseMove mouseover
--------------------------------------------------------------------------------
Mouseout mouseenter mouseleave Change Select
--------------------------------------------------------------------------------
Submit KeyDown keypress KeyUp Error
--------------------------------------------------------------------------------
Find has isn't filter is
--------------------------------------------------------------------------------
Closest index add andself parent
--------------------------------------------------------------------------------
Parents Parentsuntil Next Prev Nextall
--------------------------------------------------------------------------------
Prevall Nextuntil Prevuntil Siblings children
--------------------------------------------------------------------------------
Contents Text Wrapall Wrapinner Wrap
--------------------------------------------------------------------------------
Unwrap append prepend before after
--------------------------------------------------------------------------------
Remove empty clone HTML replacewith
--------------------------------------------------------------------------------
Detach Dommanip appendto prependto insertbefore
--------------------------------------------------------------------------------
InsertAfter ReplaceAll CSS Serialize Serializearray
--------------------------------------------------------------------------------
Ajaxstart ajaxstop ajaxcomplete ajaxerror ajaxsuccess
--------------------------------------------------------------------------------
Ajaxsend Show Hide _toggle fadeto
--------------------------------------------------------------------------------
Animate stop Slidedown Slideup slidetoggle
--------------------------------------------------------------------------------
FadeIn fadeout fadetoggle Offset position
--------------------------------------------------------------------------------
offsetparent scrollleft scrolltop innerheight outerheight
--------------------------------------------------------------------------------
Height innerwidth outerwidth Width
Re-traverse:
Copy Code code as follows:
$ ("DD"). Bind ("click", Function (e) {
var $obj = $ (e.target);
var i=0;
for (var x in $obj [0]) {
i++;
var $hr = (i%5==0)? "document.write (x+ "" + $hr);
}
});
Traversal results:
Queryselector Queryselectorall scrolltop scrollleft scrollheight
--------------------------------------------------------------------------------
ScrollWidth clienttop clientleft clientheight clientwidth
--------------------------------------------------------------------------------
Firstelementchild lastelementchild previouselementsibling nextelementsibling childelementcount
--------------------------------------------------------------------------------
Children classlist SetCapture Getelementsbyclassname getclientrects
--------------------------------------------------------------------------------
Getboundingclientrect releasecapture mozmatchesselector AddEventListener RemoveEventListener
--------------------------------------------------------------------------------
Dispatchevent style contenteditable iscontenteditable offsetparent
--------------------------------------------------------------------------------
InnerHTML offsetleft offsettop offsetheight offsetwidth
--------------------------------------------------------------------------------
scrollIntoView id title lang dir
--------------------------------------------------------------------------------
ClassName AccessKey Blur Focus Click
--------------------------------------------------------------------------------
TagName removeattributens removeattribute getattribute getElementsByTagName
--------------------------------------------------------------------------------
SetAttribute Getelementsbytagnamens hasattributens Setattributens hasattribute
--------------------------------------------------------------------------------
Getattributens nodename nodevalue NodeType parentnode
--------------------------------------------------------------------------------
ChildNodes firstchild lastchild previoussibling nextSibling
--------------------------------------------------------------------------------
Attributes ownerdocument NamespaceURI prefix localname
--------------------------------------------------------------------------------
BaseURI textcontent setuserdata Getuserdata insertbefore
--------------------------------------------------------------------------------
ReplaceChild removechild appendchild haschildnodes cloneNode
--------------------------------------------------------------------------------
Normalize issupported hasattributes comparedocumentposition Issamenode
--------------------------------------------------------------------------------
LookupPrefix isdefaultnamespace Lookupnamespaceuri Isequalnode GetAttributeNode
--------------------------------------------------------------------------------
Setattributenode Removeattributenode getattributenodens Setattributenodens Element_node
--------------------------------------------------------------------------------
Attribute_node Text_node Cdata_section_node Entity_reference_node Entity_node
--------------------------------------------------------------------------------
Processing_instruction_node Comment_node Document_node Document_type_node Document_fragment_node
--------------------------------------------------------------------------------
Notation_node document_position_disconnected document_position_preceding document_position_following DOCUMENT_ Position_contains
--------------------------------------------------------------------------------
Document_position_contained_by document_position_implementation_specific Hidden TabIndex draggable
--------------------------------------------------------------------------------
SpellCheck DataSet
So use $ ("dd") [0].tagname can get tagName.
Reference: http://www.mkyong.com/jquery/jquery-how-to-get-the-tag-name/
Then compare the results with the $ ("a") traversal
Copy Code code as follows:
$ ("a"). Bind ("click", Function (e) {
var $obj = $ (e.target);
var i=0;
for (var x in $obj) {
i++;
var $hr = (i%5==0)? "document.write (x+ "" + $hr);
}
});
Traversal results:
0 Context Length Constructor init
--------------------------------------------------------------------------------
Selector jquery size ToArray get
--------------------------------------------------------------------------------
Pushstack each ready EQ
--------------------------------------------------------------------------------
Last Slice map end push
--------------------------------------------------------------------------------
Sort Splice Extend Data removedata
--------------------------------------------------------------------------------
Queue Dequeue delay Clearqueue Promise
--------------------------------------------------------------------------------
attr removeattr prop Removeprop AddClass
--------------------------------------------------------------------------------
Removeclass Toggleclass Hasclass val Bind
--------------------------------------------------------------------------------
One unbind delegate Undelegate Trigger
--------------------------------------------------------------------------------
Triggerhandler Toggle Hover Live die
--------------------------------------------------------------------------------
Blur Focus Focusin Focusout load
--------------------------------------------------------------------------------
Resize scroll Unload click DblClick
--------------------------------------------------------------------------------
MouseDown MouseUp MouseMove mouseover mouseout
--------------------------------------------------------------------------------
MouseEnter MouseLeave Change Select Submit
--------------------------------------------------------------------------------
KeyDown keypress KeyUp Error Find
--------------------------------------------------------------------------------
has not filter is closest
--------------------------------------------------------------------------------
Index Add andself Parent Parents
--------------------------------------------------------------------------------
Parentsuntil Next prev Nextall prevall
--------------------------------------------------------------------------------
Nextuntil Prevuntil Siblings Children contents
--------------------------------------------------------------------------------
Text Wrapall Wrapinner Wrap Unwrap
--------------------------------------------------------------------------------
Append prepend before after remove
--------------------------------------------------------------------------------
Empty clone HTML ReplaceWith Detach
--------------------------------------------------------------------------------
Dommanip appendto prependto InsertBefore InsertAfter
--------------------------------------------------------------------------------
ReplaceAll CSS Serialize Serializearray ajaxstart
--------------------------------------------------------------------------------
Ajaxstop ajaxcomplete ajaxerror ajaxsuccess ajaxsend
--------------------------------------------------------------------------------
Show Hide _toggle Fadeto animate
--------------------------------------------------------------------------------
Stop Slidedown slideup slidetoggle fadeIn
--------------------------------------------------------------------------------
fadeout fadetoggle Offset Position offsetparent
--------------------------------------------------------------------------------
ScrollLeft scrolltop innerheight outerheight Height
--------------------------------------------------------------------------------
Innerwidth outerwidth Width
Re-traverse:
Copy Code code as follows:
$ ("a"). Bind ("click", Function (e) {
var $obj = $ (e.target);
var i=0;
for (var x in $obj [0]) {
i++;
var $hr = (i%5==0)? "document.write (x+ "" + $hr);
}
});
Traversal results:
jQuery16407028609993839658 queryselector Queryselectorall scrolltop scrollleft
--------------------------------------------------------------------------------
ScrollHeight scrollwidth clienttop clientleft clientheight
--------------------------------------------------------------------------------
ClientWidth firstelementchild lastelementchild previouselementsibling nextelementsibling
--------------------------------------------------------------------------------
Childelementcount Children classlist SetCapture Getelementsbyclassname
--------------------------------------------------------------------------------
Getclientrects getboundingclientrect releasecapture mozmatchesselector AddEventListener
--------------------------------------------------------------------------------
RemoveEventListener dispatchevent style contenteditable iscontenteditable
--------------------------------------------------------------------------------
offsetparent InnerHTML offsetleft offsettop offsetheight
--------------------------------------------------------------------------------
offsetwidth scrollIntoView href rel target
--------------------------------------------------------------------------------
Name Text Search Hash ID
--------------------------------------------------------------------------------
Title Lang dir className accessKey
--------------------------------------------------------------------------------
Blur Focus Click TagName removeattributens
--------------------------------------------------------------------------------
RemoveAttribute getattribute getElementsByTagName setattribute Getelementsbytagnamens
--------------------------------------------------------------------------------
Hasattributens setattributens Hasattribute Getattributens nodename
--------------------------------------------------------------------------------
NodeValue nodeType parentnode childnodes firstchild
--------------------------------------------------------------------------------
LastChild previoussibling nextSibling Attributes Ownerdocument
--------------------------------------------------------------------------------
NamespaceURI prefix localname BaseURI textcontent
--------------------------------------------------------------------------------
Setuserdata getuserdata insertbefore replacechild removechild
--------------------------------------------------------------------------------
AppendChild HasChildNodes CloneNode Normalize issupported
--------------------------------------------------------------------------------
HasAttributes comparedocumentposition Issamenode LookupPrefix isdefaultnamespace
--------------------------------------------------------------------------------
Lookupnamespaceuri Isequalnode TabIndex Element_node Attribute_node
--------------------------------------------------------------------------------
Text_node Cdata_section_node Entity_reference_node Entity_node Processing_instruction_node
--------------------------------------------------------------------------------
Comment_node Document_node Document_type_node Document_fragment_node Notation_node
--------------------------------------------------------------------------------
document_position_disconnected document_position_preceding document_position_following DOCUMENT_POSITION_CONTAINS Document_position_contained_by
--------------------------------------------------------------------------------
Document_position_implementation_specific GetAttributeNode Setattributenode Removeattributenode GetAttributeNodeNS
--------------------------------------------------------------------------------
Setattributenodens Ping Hreflang Type protocol
--------------------------------------------------------------------------------
Host hostname Port Pathname CharSet
--------------------------------------------------------------------------------
Coords rev Shape Hidden draggable
--------------------------------------------------------------------------------
SpellCheck DataSet
JQuery Get Tag Name
Copy Code code as follows:
<title>jquery Get Tag name</title>
<script type= "Text/javascript" src= "Jquery-1.3.2.min.js" ></script>
<script type= "Text/javascript" >
$ (document). Ready (function () {
var $tag = $ (' P ') [0].tagname; P
alert ($tag);
var $tag = $ ('. ClassTag1 ') [0].tagname; ' DIV '
alert ($tag);
var $tag = $ (' #idTag1 ') [0].tagname; ' DIV '
alert ($tag);
var $tag = $ (' P '). Get (0). TagName; P
alert ($tag);
var $tag = $ ('. ClassTag1 '). Get (0). TagName; ' DIV '
alert ($tag);
var $tag = $ (' #idTag1 '). Get (0). TagName; ' DIV '
alert ($tag);
});
</script>
<body>
<p>
This is Paragrah 1
</p>
<div class= "ClassTag1" >
This is class= ' ClassTag1 '
</div>
<div id= "IdTag1" >
This is id= ' IdTag1 '
</div>
</body>