Categories
JavaScript Answers

How to select DOM elements in Chrome console with JavaScript?

Spread the love

Sometimes, we want to select DOM elements in Chrome console with JavaScript.

In this article, we’ll look at how to select DOM elements in Chrome console with JavaScript.

How to select DOM elements in Chrome console with JavaScript?

To select DOM elements in Chrome console with JavaScript, we can use the console.dir method to see the selected element’s properties.

For instance, we type in:

console.dir(document.getElementById("hello"));

to select the element with ID hello with getElementById.

Then we pass that in as the argument of console.dir to see the properties of the selected element object instead of its markup.

Conclusion

To select DOM elements in Chrome console with JavaScript, we can use the console.dir method to see the selected element’s properties.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *