js获取一个对象的所以属性和值
在HTML DOM中,获取某个元素对象的时候,往往记不住它的很多属性,可以通过下面的例子来查找一下:
<!DOCTYPE html>
<html>
<body>
<h1>获取对象属性和值</h1>
<div id="div1" class="div">fdsfs</div>
<script type="text/javascript">
var myObject = document.getElementById("div1");
//遍历对象的所有属性
for (prop in myObject)
{
document.write("属性 '" + prop + "' 值为 " + myObject[prop]);
document.write("<br> ");
}
</script>
</body>
</html>
查询以后你会获得很多信息:
属性 'align' 值为
属性 'click' 值为 function click() {
[native code]
}
属性 'focus' 值为 function focus() {
[native code]
}
属性 'blur' 值为 function blur() {
[native code]
}
属性 'title' 值为
属性 'lang' 值为
属性 'dir' 值为
属性 'dataset' 值为 [object DOMStringMap]
属性 'itemScope' 值为 false
属性 'itemType' 值为
属性 'itemId' 值为
属性 'itemRef' 值为
属性 'itemProp' 值为
属性 'properties' 值为 [object HTMLPropertiesCollection]
属性 'itemValue' 值为 null
属性 'hidden' 值为 false
属性 'tabIndex' 值为 -1
属性 'accessKey' 值为
属性 'accessKeyLabel' 值为
属性 'draggable' 值为 false
属性 'contentEditable' 值为 inherit
属性 'isContentEditable' 值为 false
属性 'contextMenu' 值为 null
属性 'spellcheck' 值为 false
属性 'style' 值为 [object CSS2Properties]
属性 'oncopy' 值为 null
属性 'oncut' 值为 null
属性 'onpaste' 值为 null
属性 'offsetParent' 值为 [object HTMLBodyElement]
属性 'offsetTop' 值为 86
属性 'offsetLeft' 值为 8
属性 'offsetWidth' 值为 600
属性 'offsetHeight' 值为 22
属性 'onabort' 值为 null
属性 'onblur' 值为 null
属性 'onfocus' 值为 null
属性 'oncanplay' 值为 null
属性 'oncanplaythrough' 值为 null
属性 'onchange' 值为 null
属性 'onclick' 值为 null
属性 'oncontextmenu' 值为 null
属性 'ondblclick' 值为 null
属性 'ondrag' 值为 null
属性 'ondragend' 值为 null
属性 'ondragenter' 值为 null
属性 'ondragleave' 值为 null
属性 'ondragover' 值为 null
属性 'ondragstart' 值为 null
属性 'ondrop' 值为 null
属性 'ondurationchange' 值为 null
属性 'onemptied' 值为 null
属性 'onended' 值为 null
属性 'oninput' 值为 null
属性 'oninvalid' 值为 null
属性 'onkeydown' 值为 null
属性 'onkeypress' 值为 null
属性 'onkeyup' 值为 null
属性 'onload' 值为 null
属性 'onloadeddata' 值为 null
属性 'onloadedmetadata' 值为 null
属性 'onloadstart' 值为 null
属性 'onmousedown' 值为 null
属性 'onmouseenter' 值为 null
属性 'onmouseleave' 值为 null
属性 'onmousemove' 值为 null
属性 'onmouseout' 值为 null
属性 'onmouseover' 值为 null
属性 'onmouseup' 值为 null
属性 'onpause' 值为 null
属性 'onplay' 值为 null
属性 'onplaying' 值为 null
属性 'onprogress' 值为 null
属性 'onratechange' 值为 null
属性 'onreset' 值为 null
属性 'onresize' 值为 null
属性 'onscroll' 值为 null
属性 'onseeked' 值为 null
属性 'onseeking' 值为 null
属性 'onselect' 值为 null
属性 'onshow' 值为 null
属性 'onstalled' 值为 null
属性 'onsubmit' 值为 null
属性 'onsuspend' 值为 null
属性 'ontimeupdate' 值为 null
属性 'onvolumechange' 值为 null
属性 'onwaiting' 值为 null
属性 'onmozfullscreenchange' 值为 null
属性 'onmozfullscreenerror' 值为 null
属性 'onmozpointerlockchange' 值为 null
属性 'onmozpointerlockerror' 值为 null
属性 'onerror' 值为 null
属性 'getAttribute' 值为 function getAttribute() {
[native code]
}
属性 'getAttributeNS' 值为 function getAttributeNS() {
[native code]
}
属性 'setAttribute' 值为 function setAttribute() {
[native code]
}
属性 'setAttributeNS' 值为 function setAttributeNS() {
[native code]
}
属性 'removeAttribute' 值为 function removeAttribute() {
[native code]
}
属性 'removeAttributeNS' 值为 function removeAttributeNS() {
[native code]
}
属性 'hasAttribute' 值为 function hasAttribute() {
[native code]
}
属性 'hasAttributeNS' 值为 function hasAttributeNS() {
[native code]
}
属性 'hasAttributes' 值为 function hasAttributes() {
[native code]
}
属性 'closest' 值为 function closest() {
[native code]
}
属性 'matches' 值为 function matches() {
[native code]
}
属性 'getElementsByTagName' 值为 function getElementsByTagName() {
[native code]
}
属性 'getElementsByTagNameNS' 值为 function getElementsByTagNameNS() {
[native code]
}
属性 'getElementsByClassName' 值为 function getElementsByClassName() {
[native code]
}
属性 'mozMatchesSelector' 值为 function mozMatchesSelector() {
[native code]
}
属性 'setCapture' 值为 function setCapture() {
[native code]
}
属性 'releaseCapture' 值为 function releaseCapture() {
[native code]
}
属性 'mozRequestFullScreen' 值为 function mozRequestFullScreen() {
[native code]
}
属性 'mozRequestPointerLock' 值为 function mozRequestPointerLock() {
[native code]
}
属性 'getAttributeNode' 值为 function getAttributeNode() {
[native code]
}
属性 'setAttributeNode' 值为 function setAttributeNode() {
[native code]
}
属性 'removeAttributeNode' 值为 function removeAttributeNode() {
[native code]
}
属性 'getAttributeNodeNS' 值为 function getAttributeNodeNS() {
[native code]
}
属性 'setAttributeNodeNS' 值为 function setAttributeNodeNS() {
[native code]
}
属性 'getClientRects' 值为 function getClientRects() {
[native code]
}
属性 'getBoundingClientRect' 值为 function getBoundingClientRect() {
[native code]
}
属性 'scrollIntoView' 值为 function scrollIntoView() {
[native code]
}
属性 'scroll' 值为 function scroll() {
[native code]
}
属性 'scrollTo' 值为 function scrollTo() {
[native code]
}
属性 'scrollBy' 值为 function scrollBy() {
[native code]
}
属性 'insertAdjacentHTML' 值为 function insertAdjacentHTML() {
[native code]
}
属性 'querySelector' 值为 function querySelector() {
[native code]
}
属性 'querySelectorAll' 值为 function querySelectorAll() {
[native code]
}
属性 'remove' 值为 function remove() {
[native code]
}
属性 'tagName' 值为 DIV
属性 'id' 值为 div1
属性 'className' 值为 div
属性 'classList' 值为 div
属性 'attributes' 值为 [object NamedNodeMap]
属性 'onwheel' 值为 null
属性 'scrollTop' 值为 0
属性 'scrollLeft' 值为 0
属性 'scrollWidth' 值为 600
属性 'scrollHeight' 值为 22
属性 'clientTop' 值为 0
属性 'clientLeft' 值为 0
属性 'clientWidth' 值为 600
属性 'clientHeight' 值为 22
属性 'scrollTopMax' 值为 0
属性 'scrollLeftMax' 值为 0
属性 'innerHTML' 值为 fdsfs
属性 'outerHTML' 值为
属性 'previousElementSibling' 值为 [object HTMLHeadingElement]
属性 'nextElementSibling' 值为 [object HTMLScriptElement]
属性 'children' 值为 [object HTMLCollection]
属性 'firstElementChild' 值为 null
属性 'lastElementChild' 值为 null
属性 'childElementCount' 值为 0
属性 'hasChildNodes' 值为 function hasChildNodes() {
[native code]
}
属性 'insertBefore' 值为 function insertBefore() {
[native code]
}
属性 'appendChild' 值为 function appendChild() {
[native code]
}
属性 'replaceChild' 值为 function replaceChild() {
[native code]
}
属性 'removeChild' 值为 function removeChild() {
[native code]
}
属性 'normalize' 值为 function normalize() {
[native code]
}
属性 'cloneNode' 值为 function cloneNode() {
[native code]
}
属性 'isEqualNode' 值为 function isEqualNode() {
[native code]
}
属性 'compareDocumentPosition' 值为 function compareDocumentPosition() {
[native code]
}
属性 'contains' 值为 function contains() {
[native code]
}
属性 'lookupPrefix' 值为 function lookupPrefix() {
[native code]
}
属性 'lookupNamespaceURI' 值为 function lookupNamespaceURI() {
[native code]
}
属性 'isDefaultNamespace' 值为 function isDefaultNamespace() {
[native code]
}
属性 'nodeType' 值为 1
属性 'nodeName' 值为 DIV
属性 'baseURI' 值为 http://www.runoob.com/try/demo_source/result.php?x=0.5273678891388178
属性 'ownerDocument' 值为 [object HTMLDocument]
属性 'parentNode' 值为 [object HTMLBodyElement]
属性 'parentElement' 值为 [object HTMLBodyElement]
属性 'childNodes' 值为 [object NodeList]
属性 'firstChild' 值为 [object Text]
属性 'lastChild' 值为 [object Text]
属性 'previousSibling' 值为 [object Text]
属性 'nextSibling' 值为 [object Text]
属性 'nodeValue' 值为 null
属性 'textContent' 值为 fdsfs
属性 'namespaceURI' 值为 http://www.w3.org/1999/xhtml
属性 'prefix' 值为 null
属性 'localName' 值为 div
属性 'ELEMENT_NODE' 值为 1
属性 'ATTRIBUTE_NODE' 值为 2
属性 'TEXT_NODE' 值为 3
属性 'CDATA_SECTION_NODE' 值为 4
属性 'ENTITY_REFERENCE_NODE' 值为 5
属性 'ENTITY_NODE' 值为 6
属性 'PROCESSING_INSTRUCTION_NODE' 值为 7
属性 'COMMENT_NODE' 值为 8
属性 'DOCUMENT_NODE' 值为 9
属性 'DOCUMENT_TYPE_NODE' 值为 10
属性 'DOCUMENT_FRAGMENT_NODE' 值为 11
属性 'NOTATION_NODE' 值为 12
属性 'DOCUMENT_POSITION_DISCONNECTED' 值为 1
属性 'DOCUMENT_POSITION_PRECEDING' 值为 2
属性 'DOCUMENT_POSITION_FOLLOWING' 值为 4
属性 'DOCUMENT_POSITION_CONTAINS' 值为 8
属性 'DOCUMENT_POSITION_CONTAINED_BY' 值为 16
属性 'DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC' 值为 32
属性 'addEventListener' 值为 function addEventListener() {
[native code]
}
属性 'removeEventListener' 值为 function removeEventListener() {
[native code]
}
属性 'dispatchEvent' 值为 function dispatchEvent() {
[native code]
}
上面黑体的几乎就是最常见的属性了,其他的可能都不太见过。。。
js获取一个对象的所以属性和值的更多相关文章
- js 获取和设置css3 属性值的实现方法
众多周知 CSS3 增加了很多属性,在读写的时候就没有原先那么方便了. 如:<div style="left:100px"></div> 只考虑行间样式的话 ...
- jquery】常用的jquery获取表单对象的属性与值
[jquery]常用的jquery获取表单对象的属性与值 1.JQuery的概念 JQuery是一个JavaScript的类库,这个类库集合了很多功能方法,利用类库你可以用一些简单的代码实现一些复杂的 ...
- js-取值&赋值-获取某标签某属性的值
js 取值&赋值-获取某标签某属性的值 CreateTime--2016年10月16日16:35:34 Author:Marydon 1.取值 //方法一 //自定义属性必须用getAtt ...
- js获取键盘按下的键值event.keyCode,event.charCode,event.which的兼容性
js获取键盘按下的键值有event.keyCode,event.charCode和event.which 其中: 谷歌浏览器对event.keyCode,event.charCode和event.wh ...
- bootstrap selectpicker 通过代码指定选中值 BootStrap selectpicker后台动态绑定数据 selectpicker 获取选中option的属性或者值
bootstrap-select使用 bootstrap selectpicker 通过代码指定选中值 $('#subjectno').selectpicker('val',(row.subjectn ...
- JS获取select的value和text值的简单实例
本篇文章主要是对JS获取select的value和text值的简单实例进行了介绍,需要的朋友可以过来参考下,希望对大家有所帮助 代码如下: <select id = "cityList ...
- js获取object类型所有的键值对
万物皆对象,而对象完全可以用键值对来表示,所以,在js中,也是通过键值对来表示对象的,在开发中,我在修改的时候,知道属性值可以直接用点.符号来获取值,但是写common.js的时候,发现这个属性名称是 ...
- js中遍历对象的属性和值
今天想看一下js的数组遍历的内容,搜索到了一个关于对象遍历写好的函数,保留一下.以后好用. function allPrpos ( obj ) { // 用来保存所有的属性名称和值 var p ...
- JS获取table表格任意单元格值
jsp页面表格布局 <body onload="show()"> <center> <input type="text" valu ...
随机推荐
- LeetCode 242 Valid Anagram
Problem: Given two strings s and t, write a function to determine if t is an anagram of s. For examp ...
- August 22nd 2016 Week 35th Monday
Have you ever given any thought to your future? 你有没有为将来打算过呢? Have you ever given any thought to your ...
- maven配置httpclient3.X jar包
<dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging& ...
- 4.3 map和multimap
使用map multimap必须包含头文件map *:multimap 1)multimap定义 template<class Key,class Pred=less<Key>,cl ...
- 解决git客户端MINGW32下的“Could not open a connection to your authentication agent.”
使用git, 下载客户端后想进行和github 进行ssh 互通 出现以下情况: hadoop@deng-PC MINGW32 ~/.ssh$ ssh-add ~/.ssh/id_rsaCould n ...
- Pyqt QListWidget 展示系统环境变量
今天学习了下Pyqt的 QListWidget 控件 我们先看下这个图片 这张图片就是典型的listWidget效果,我们今天就仿这样布局新建个ListWidget 在网上找了个关于QListWidg ...
- 【Java EE 学习 21 上】【其它类型的监听器】【使用HttpSessionActivationListener监听session的活化和钝化】
一.ServletContextListener Method Summary void contextDestroyed(ServletContextEvent sce) R ...
- 【JAVA线程间通信技术】
之前的例子都是多个线程执行同一种任务,下面开始讨论多个线程执行不同任务的情况. 举个例子:有个仓库专门存储货物,有的货车专门将货物送往仓库,有的货车则专门将货物拉出仓库,这两种货车的任务不同,而且为了 ...
- POJ2406 Power Strings(KMP,后缀数组)
这题可以用后缀数组,KMP方法做 后缀数组做法开始想不出来,看的题解,方法是枚举串长len的约数k,看lcp(suffix(0), suffix(k))的长度是否为n- k ,若为真则len / k即 ...
- [Tools] 使用XP远程登录Win8系统
[背景] 完成最基本的设置后,发现xp依然不能远程访问win8桌面,搜索后发现需要进一步设置 [开工] 按照参考资料进行设置,下面的参考资料已经写的很详细了,只是参考资料2中的文件名: redss ...