Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
569 views
in Technique[技术] by (71.8m points)

如何在chrome控制台查看元素节点的属性

通常获取元素节点控制台显示
3610DCFE-7733-476A-AC1C-97E890C3E55B.png
而我希望能以属性集合的方式查看,如下
222.png
除了用document.querySelectorAll()方法返回节点集合以外,还有其他方法吗?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

几种方式,看你喜欢用哪一个了。


一是格式化:

console.log('%O', myElement)

二是用非公开的 API:

console.dir(myElement);
https://developer.mozilla.org...

三是转换成数组:

console.log([myElement]);

几种方式的执行结果截图:

image.png

image.png

image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...