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.