先来看一段代码:
var dom = document.querySelector('body');for(var i in dom){ console.log(i,dom[i])}
可以看到很多,来整理一下,总共有三大类(我自己分的,没有科学依据)
除了一些私有属性、方法(比如a的私有属性href等)和一些空的属性
attributes
events
methods
attributes
根据value类型又分为了几个小分类:
1.普通属性
text
link vLink aLink title lang translate truedir hidden falsetabIndex -1accessKey draggable falsespellcheck truecontentEditable inheritisContentEditable falseinnerText imagesFeaturesouterText webkitdropzonenamespaceURI prefix nullinnerHTML outerHTMLshadowRoot nullbaseURI isConnected truebaseURI isConnected truenodeValue nulltextContent2.样式属性
bgColor
background offsetTop 0offsetLeft 0offsetWidth 1333offsetHeight 50scrollTop 0scrollLeft 0scrollWidth 1333scrollHeight 950clientTop 0clientLeft 0clientWidth 1333clientHeight 503.dom操作属性
offsetParent null
localName bodytagName BODYpreviousElementSibling nextElementSiblingchildren firstElementChild lastElementChild childElementCount nodeType 1nodeName BODYownerDocument #documentparentNode parentElement childNodes firstChild lastChild previousSibling nextSibling null4.其他对象属性
style CSSStyleDeclaration {}
dataset DOMStringMap {}attributes NamedNodeMap {length: 0}5.我不知道的类型
ELEMENT_NODE 1
ATTRIBUTE_NODE 2TEXT_NODE 3CDATA_SECTION_NODE 4ENTITY_REFERENCE_NODE 5ENTITY_NODE 6PROCESSING_INSTRUCTION_NODE 7COMMENT_NODE 8DOCUMENT_NODE 9DOCUMENT_TYPE_NODE 10DOCUMENT_FRAGMENT_NODE 11NOTATION_NODE 12DOCUMENT_POSITION_DISCONNECTED 1DOCUMENT_POSITION_PRECEDING 2DOCUMENT_POSITION_FOLLOWING 4DOCUMENT_POSITION_CONTAINS 8DOCUMENT_POSITION_CONTAINED_BY 16DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC 32events
onbeforecopy null
onbeforecut nullonbeforepaste nulloncopy nulloncut nullonpaste nullonsearch nullonselectstart nullonwheel nullonwebkitfullscreenchange nullonwebkitfullscreenerror nullonblur nullonerror nullonfocus nullonload nullonresize nullonscroll nullonbeforeunload nullonhashchange nullonlanguagechange nullonmessage nullonoffline nullononline nullonpagehide nullonpageshow nullonpopstate nullonstorage nullonunload nullonorientationchange nullonrejectionhandled nullonunhandledrejection nullonabort nulloncancel nulloncanplay nulloncanplaythrough nullonchange nullonclick nullonclose nulloncontextmenu nulloncuechange nullondblclick nullondrag nullondragend nullondragenter nullondragleave nullondragover nullondragstart nullondrop nullondurationchange nullonemptied nullonended nulloninput nulloninvalid nullonkeydown nullonkeypress nullonkeyup nullonloadeddata nullonloadedmetadata nullonloadstart nullonmousedown nullonmouseenter nullonmouseleave nullonmousemove nullonmouseout nullonmouseover nullonmouseup nullonmousewheel nullonpause nullonplay nullonplaying nullonprogress nullonratechange nullonreset nullonseeked nullonseeking nullonselect nullonshow nullonstalled nullonsubmit nullonsuspend nullontimeupdate nullontoggle nullonvolumechange nullonwaiting nullontouchcancel nullontouchend nullontouchmove nullontouchstart nullmethods
click click() { [native code] }
focus focus() { [native code] }blur blur() { [native code] }hasAttributes hasAttributes() { [native code] }getAttribute getAttribute() { [native code] }getAttributeNS getAttributeNS() { [native code] }setAttribute setAttribute() { [native code] }setAttributeNS setAttributeNS() { [native code] }removeAttribute removeAttribute() { [native code] }removeAttributeNS removeAttributeNS() { [native code] }hasAttribute hasAttribute() { [native code] }hasAttributeNS hasAttributeNS() { [native code] }getAttributeNode getAttributeNode() { [native code] }getAttributeNodeNS getAttributeNodeNS() { [native code] }setAttributeNode setAttributeNode() { [native code] }setAttributeNodeNS setAttributeNodeNS() { [native code] }removeAttributeNode removeAttributeNode() { [native code] }closest closest() { [native code] }matches matches() { [native code] }webkitMatchesSelector webkitMatchesSelector() { [native code] }getElementsByTagName getElementsByTagName() { [native code] }getElementsByTagNameNS getElementsByTagNameNS() { [native code] }getElementsByClassName getElementsByClassName() { [native code] }insertAdjacentElement insertAdjacentElement() { [native code] }insertAdjacentText insertAdjacentText() { [native code] }insertAdjacentHTML insertAdjacentHTML() { [native code] }createShadowRoot createShadowRoot() { [native code] }getDestinationInsertionPoints getDestinationInsertionPoints() { [native code] }requestPointerLock requestPointerLock() { [native code] }getClientRects getClientRects() { [native code] }getBoundingClientRect getBoundingClientRect() { [native code] }scrollIntoView scrollIntoView() { [native code] }scrollIntoViewIfNeeded scrollIntoViewIfNeeded() { [native code] }animate animate() { [native code] }remove remove() { [native code] }webkitRequestFullScreen webkitRequestFullScreen() { [native code] }webkitRequestFullscreen webkitRequestFullscreen() { [native code] }querySelector querySelector() { [native code] }querySelectorAll querySelectorAll() { [native code] }hasChildNodes hasChildNodes() { [native code] }normalize normalize() { [native code] }cloneNode cloneNode() { [native code] }isEqualNode isEqualNode() { [native code] }isSameNode isSameNode() { [native code] }compareDocumentPosition compareDocumentPosition() { [native code] }contains contains() { [native code] }lookupPrefix lookupPrefix() { [native code] }lookupNamespaceURI lookupNamespaceURI() { [native code] }isDefaultNamespace isDefaultNamespace() { [native code] }insertBefore insertBefore() { [native code] }appendChild appendChild() { [native code] }replaceChild replaceChild() { [native code] }removeChild removeChild() { [native code] }addEventListener addEventListener() { [native code] }removeEventListener removeEventListener() { [native code] }dispatchEvent dispatchEvent() { [native code] }下一节详细分析