Code sharing for Traversing jquery objects _ jquery

Source: Internet
Author: User
Tags baseuri
I encountered a problem today. I need to get the tagName. I used jquery to query it. We use $ (& quot; dd & quot ;). attr (& quot; tagName & quot;) can be obtained, but the returned value is undefined. As a result, after a long query, the returned result traverses the jquery encapsulated object. The Code is as follows:


$ ("Dd"). bind ("click", function (e ){
Var $ obj = require (e.tar get );
Var I = 0;
For (var x in $ obj ){
I ++;
Var $ hr = (I % 5 = 0 )? "

":"";
Document. write (x + "" + $ hr );
}
});


Traversal result:
0 length prevObject context selector
--------------------------------------------------------------------------------
Constructor init jquery size toArray
--------------------------------------------------------------------------------
Get pushStack each ready eq
--------------------------------------------------------------------------------
First 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
Traverse again:

The Code is as follows:


$ ("Dd"). bind ("click", function (e ){
Var $ obj = require (e.tar get );
Var I = 0;
For (var x in $ obj [0]) {
I ++;
Var $ hr = (I % 5 = 0 )? "

":"";
Document. write (x + "" + $ hr );
}
});


Traversal result:
QuerySelector querySelectorAll scrollTop scrollLeft scrollHeight
--------------------------------------------------------------------------------
ScrollWidth clientTop clientLeft clientHeight clientWidth
--------------------------------------------------------------------------------
FirstElementChild lastElementChild previuselementsibling nextElementSibling childElementCount
--------------------------------------------------------------------------------
Children classList setCapture getElementsByClassName getClientRects
--------------------------------------------------------------------------------
GetBoundingClientRect releaseCapture initialize matchesselector 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 previussibling nextSibling
--------------------------------------------------------------------------------
Attributes ownerDocument namespaceURI prefix localName
--------------------------------------------------------------------------------
BaseURI textContent setUserData getUserData insertBefore
--------------------------------------------------------------------------------
ReplaceChild removeChild appendChild hasChildNodes cloneNode
--------------------------------------------------------------------------------
Normalize isSupported hasAttributes compareDocumentPosition isSameNode
--------------------------------------------------------------------------------
LookupPrefix isDefaultNamespace lookupNamespaceURI is?node 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
Therefore, $ ("dd") [0]. tagName can be used to obtain the tagName.
Reference: http://www.mkyong.com/jquery/jquery-how-to-get-the-tag-name/
Then compare with the result of traversing $ ("")

The Code is as follows:


$ ("A"). bind ("click", function (e ){
Var $ obj = require (e.tar get );
Var I = 0;
For (var x in $ obj ){
I ++;
Var $ hr = (I % 5 = 0 )? "

":"";
Document. write (x + "" + $ hr );
}
});


Traversal result:
0 context length constructor init
--------------------------------------------------------------------------------
Selector jquery size toArray get
--------------------------------------------------------------------------------
PushStack each ready eq first
--------------------------------------------------------------------------------
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

Traverse again:

The Code is as follows:


$ ("A"). bind ("click", function (e ){
Var $ obj = require (e.tar get );
Var I = 0;
For (var x in $ obj [0]) {
I ++;
Var $ hr = (I % 5 = 0 )? "

":"";
Document. write (x + "" + $ hr );
}
});


Traversal result:
Jquery16407028609993842558 querySelector querySelectorAll scrollTop scrollLeft
--------------------------------------------------------------------------------
ScrollHeight scrollWidth clientTop clientLeft clientHeight
--------------------------------------------------------------------------------
ClientWidth firstElementChild lastElementChild previuselementsibling nextElementSibling
--------------------------------------------------------------------------------
ChildElementCount children classList setCapture getElementsByClassName
--------------------------------------------------------------------------------
GetClientRects getBoundingClientRect releaseCapture implements matchesselector 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 previussibling nextSibling attributes ownerDocument
--------------------------------------------------------------------------------
NamespaceURI prefix localName baseURI textContent
--------------------------------------------------------------------------------
SetUserData getUserData insertBefore replaceChild removeChild
--------------------------------------------------------------------------------
AppendChild hasChildNodes cloneNode normalize isSupported
--------------------------------------------------------------------------------
HasAttributes compareDocumentPosition isSameNode lookupPrefix isDefaultNamespace
--------------------------------------------------------------------------------
LookupNamespaceURI isw.node 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

The Code is as follows:




JQuery Get Tag Name

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.