JS gets the properties and values of an object

Source: Internet
Author: User

In the HTML DOM, when you get an element object, you often don't remember many of its properties, and you can look it up in the following example:

1 <!DOCTYPE HTML>2 <HTML>3 <Body>4     <H1>Get Object properties and values</H1>5     <DivID= "Div1"class= "Div">Fdsfs</Div>6 <Scripttype= "Text/javascript"> 7 varMyObject=document.getElementById ("Div1"); 8 //Traverse all properties of an object9  for(PropinchmyObject)Ten {  One document.write ("Properties '" +prop+ "' value is" +Myobject[prop]);  A document.write ("<br>");  - }  - </Script>  the </Body> - </HTML> -             

You will get a lot of information after the query:

The property ' align ' value is
property ' Click ' Value is function click () {[native code]}
property ' Focus ' value is function focus () {[native code]}
property ' blur ' value is function blur () {[native code]}
The property ' title ' value is
The property ' lang ' value is
The property ' dir ' value is
Property ' DataSet ' value is [object Domstringmap]
Property ' Itemscope ' value is False
The property ' ItemType ' value is
The property ' ItemId ' value is
The property ' Itemref ' value is
The property ' Itemprop ' value is
Property ' Properties ' value is [object Htmlpropertiescollection]
Property ' Itemvalue ' value is null
property ' hidden ' value is false
property ' TabIndex ' value is-1
The property ' AccessKey ' value is
The property ' Accesskeylabel ' value is
Property ' Draggable ' value is False
Property ' contenteditable ' value is inherit
Property ' Iscontenteditable ' value is False
Property ' ContextMenu ' value is null
Property ' SpellCheck ' value is False
Property ' style ' value is [object Css2properties]
Property ' oncopy ' value is null
Property ' Oncut ' value is null
Property ' Onpaste ' value is null
Property ' OffsetParent ' value is [object Htmlbodyelement]
Property ' OffsetTop ' value is 86
Property ' Offsetleft ' value is 8
Property ' offsetwidth ' value is 600
Property ' offsetheight ' value is 22
Property ' onabort ' value is null
Property ' onblur ' value is null
Property ' onfocus ' value is null
Property ' Oncanplay ' value is null
Property ' Oncanplaythrough ' value is null
Property ' onchange ' value is null
Property ' onclick ' value is null
Property ' OnContextMenu ' value is null
Property ' ondblclick ' value is null
Property ' Ondrag ' value is null
Property ' Ondragend ' value is null
Property ' OnDragEnter ' value is null
Property ' OnDragLeave ' value is null
Property ' OnDragOver ' value is null
Property ' ondragstart ' value is null
Property ' OnDrop ' value is null
Property ' Ondurationchange ' value is null
Property ' onemptied ' value is null
Property ' onended ' value is null
Property ' Oninput ' value is null
Property ' Oninvalid ' value is null
Property ' onkeydown ' value is null
Property ' onkeypress ' value is null
Property ' onkeyup ' value is null
Property ' onload ' value is null
Property ' Onloadeddata ' value is null
Property ' Onloadedmetadata ' value is null
Property ' Onloadstart ' value is null
Property ' onmousedown ' value is null
Property ' Onmouseenter ' value is null
Property ' OnMouseLeave ' value is null
Property ' onmousemove ' value is null
Property ' onmouseout ' value is null
Property ' onmouseover ' value is null
Property ' onmouseup ' value is null
Property ' OnPause ' value is null
Property ' Onplay ' value is null
Property ' onplaying ' value is null
Property ' OnProgress ' value is null
Property ' Onratechange ' value is null
Property ' OnReset ' value is null
Property ' onresize ' value is null
Property ' onscroll ' value is null
Property ' onseeked ' value is null
Property ' onseeking ' value is null
Property ' onselect ' value is null
Property ' OnShow ' value is null
Property ' onstalled ' value is null
Property ' onsubmit ' value is null
Property ' Onsuspend ' value is null
Property ' ontimeupdate ' value is null
Property ' Onvolumechange ' value is null
Property ' onwaiting ' value is null
Property ' Onmozfullscreenchange ' value is null
Property ' Onmozfullscreenerror ' value is null
Property ' Onmozpointerlockchange ' value is null
Property ' Onmozpointerlockerror ' value is null
Property ' onerror ' value is null
Property ' getattribute ' value is function getattribute () {[native code]}
Property ' Getattributens ' value is function Getattributens () {[native code]}
Property ' SetAttribute ' value is function SetAttribute () {[native code]}
Property ' Setattributens ' value is function Setattributens () {[native code]}
Property ' RemoveAttribute ' value is function removeattribute () {[native code]}
Property ' Removeattributens ' value is function Removeattributens () {[native code]}
Property ' Hasattribute ' value is function Hasattribute () {[native code]}
Property ' Hasattributens ' value is function Hasattributens () {[native code]}
Property ' HasAttributes ' value is function hasattributes () {[native code]}
Property ' closest ' value is function closest () {[native code]}
Property ' matches ' value is function matches () {[native code]}
Property ' getElementsByTagName ' value is function getElementsByTagName () {[native code]}
Property ' Getelementsbytagnamens ' value is function Getelementsbytagnamens () {[native code]}
Property ' Getelementsbyclassname ' value is function getelementsbyclassname () {[native code]}
Property ' Mozmatchesselector ' value is function mozmatchesselector () {[native code]}
Property ' SetCapture ' value is function setcapture () {[native code]}
Property ' ReleaseCapture ' value is function releasecapture () {[native code]}
Property ' Mozrequestfullscreen ' value is function Mozrequestfullscreen () {[native code]}
Property ' Mozrequestpointerlock ' value is function Mozrequestpointerlock () {[native code]}
Property ' GetAttributeNode ' value is function GetAttributeNode () {[native code]}
Property ' Setattributenode ' value is function Setattributenode () {[native code]}
Property ' Removeattributenode ' value is function Removeattributenode () {[native code]}
Property ' Getattributenodens ' value is function Getattributenodens () {[native code]}
Property ' Setattributenodens ' value is function Setattributenodens () {[native code]}
Property ' getclientrects ' value is function getclientrects () {[native code]}
Property ' Getboundingclientrect ' value is function getboundingclientrect () {[native code]}
Property ' scrollIntoView ' value is function scrollIntoView () {[native code]}
Property ' Scroll ' value is function scroll () {[native code]}
Property ' ScrollTo ' value is function scrollTo () {[native code]}
Property ' Scrollby ' value is function Scrollby () {[native code]}
Property ' insertadjacenthtml ' value is function insertadjacenthtml () {[native code]}
Property ' Queryselector ' value is function queryselector () {[native code]}
Property ' Queryselectorall ' value is function Queryselectorall () {[native code]}
Property ' Remove ' value is function remove () {[native code]}
attribute ' tagName ' value is DIV
property ' id ' value is div1
attribute ' className ' value is div
attribute ' classlist ' value is div
Property ' attributes ' value is [object NamedNodeMap]
Property ' Onwheel ' value is null
Property ' scrolltop ' value is 0
Property ' ScrollLeft ' value is 0
Property ' ScrollWidth ' value is 600
Property ' ScrollHeight ' value is 22
Property ' ClientTop ' value is 0
Property ' ClientLeft ' value is 0
attribute ' clientwidth ' value is
attribute ' clientheight ' value is
Property ' Scrolltopmax ' value is 0
Property ' Scrollleftmax ' value is 0
property ' InnerHTML ' value is Fdsfs
the property ' outerhtml ' value is

Fdsfs


Property ' previouselementsibling ' value is [object Htmlheadingelement]
Property ' nextelementsibling ' value is [object Htmlscriptelement]
Property ' Children ' value is [object Htmlcollection]
Property ' Firstelementchild ' value is null
Property ' Lastelementchild ' value is null
Property ' Childelementcount ' value is 0
Property ' HasChildNodes ' value is function haschildnodes () {[native code]}
Property ' InsertBefore ' value is function insertbefore () {[native code]}
Property ' appendchild ' value is function appendchild () {[native code]}
Property ' ReplaceChild ' value is function replacechild () {[native code]}
Property ' RemoveChild ' value is function removechild () {[native code]}
Property ' normalize ' value is function normalize () {[native code]}
Property ' CloneNode ' value is function CloneNode () {[native code]}
Property ' Isequalnode ' value is function Isequalnode () {[native code]}
Property ' comparedocumentposition ' value is function comparedocumentposition () {[native code]}
Property ' contains ' value is function contains () {[native code]}
Property ' LookupPrefix ' value is function LookupPrefix () {[native code]}
Property ' Lookupnamespaceuri ' value is function Lookupnamespaceuri () {[native code]}
Property ' Isdefaultnamespace ' value is function isdefaultnamespace () {[native code]}
Property ' NodeType ' value is 1
Attribute ' NodeName ' value is DIV
Property ' BaseURI ' value is http://www.runoob.com/try/demo_source/result.php?x=0.5273678891388178
Property ' ownerdocument ' value is [object HTMLDocument]
Property ' parentnode ' value is [object Htmlbodyelement]
Property ' parentelement ' value is [object Htmlbodyelement]
Property ' ChildNodes ' value is [object NodeList]
Property ' FirstChild ' value is [object Text]
Property ' LastChild ' value is [object Text]
Property ' previoussibling ' value is [object Text]
Property ' nextSibling ' value is [object Text]
Property ' NodeValue ' value is null
Property ' Textcontent ' value is FDSFS
Property ' NamespaceURI ' value is http://www.w3.org/1999/xhtml
Property ' prefix ' value is null
Attribute ' LocalName ' value is div
Property ' Element_node ' value is 1
Property ' Attribute_node ' value is 2
Property ' Text_node ' value is 3
Property ' Cdata_section_node ' value is 4
Property ' Entity_reference_node ' value is 5
Property ' Entity_node ' value is 6
Property ' Processing_instruction_node ' value is 7
Property ' Comment_node ' value is 8
Property ' Document_node ' value is 9
Property ' Document_type_node ' value is 10
Property ' Document_fragment_node ' value is 11
Property ' Notation_node ' value is 12
Property ' document_position_disconnected ' value is 1
Property ' Document_position_preceding ' value is 2
Property ' document_position_following ' value is 4
Property ' Document_position_contains ' value is 8
Property ' document_position_contained_by ' value is 16
Property ' Document_position_implementation_specific ' value is 32
Property ' AddEventListener ' value is function AddEventListener () {[native code]}
Property ' RemoveEventListener ' value is function RemoveEventListener () {[native code]}
Property ' dispatchevent ' value is function dispatchevent () {[native code]}

The above is almost the most common property of the black, the other may not be too seen ...

JS gets the properties and values of an object

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.