how can i console the list of DOM object with javascript - Stack Overflow

when i get an element with jQuery and console.log() the element i can see all methods that i can do som

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
Add a ment  | 

3 Answers 3

Reset to default 3

You 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"));

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745477911a4629430.html

相关推荐

  • how can i console the list of DOM object with javascript - Stack Overflow

    when i get an element with jQuery and console.log() the element i can see all methods that i can do som

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信