admin管理员组文章数量:1431398
when i get an element with jQuery and console.log() the element i can see all methods that i can do something with. but when i use javascript to show element in console it just show the element itself instead of show me methods like _.style _.accessKey and so on, like when i do $(this)[0] with jQuery. so how to see all these methods in pure javascript ?
when i get an element with jQuery and console.log() the element i can see all methods that i can do something with. but when i use javascript to show element in console it just show the element itself instead of show me methods like _.style _.accessKey and so on, like when i do $(this)[0] with jQuery. so how to see all these methods in pure javascript ?
Share Improve this question edited Nov 16, 2018 at 17:09 Amir Rezvani asked Nov 14, 2018 at 16:59 Amir RezvaniAmir Rezvani 1,51413 silver badges40 bronze badges 1- 1 a console log in most browsers wil show you the whole object including its methods and properties. Else you can write your own traversal function and print them out using console.log – Nikos M. Commented Nov 14, 2018 at 17:02
3 Answers
Reset to default 3You can try the following:-
var div = document.getElementsByTagName('div')[0];
console.table(div) or console.dir(div)
This will print out all the properties available in a neat table format.
use console.dir() to see all the methods for javascript DOM object.
You can try following ways to find html elements:
var x = document.getElementById('id');
console.log(x);
var y = document.getElementsByTagName('tag_name');
console.log(y);
var z = document.getElementsByClassName('class_name');
console.log(z);
and then list all methods and properties associated with that element by creating one new object and then call the function
function getAllMethods(object) {
return Object.getOwnPropertyNames(object).filter(function(property) {
return typeof object[property] == 'function';
}
console.log(getAllMethods("object"));
本文标签: how can i console the list of DOM object with javascriptStack Overflow
版权声明:本文标题:how can i console the list of DOM object with javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745477911a2660046.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论