When you select Inspect Element
with Chrome, at the bottom of the Developer's panel, a path to that element is shown.
In this instance, it was body > div#divsinglecolumnwidth.singlecolumnwidth > div#productdescription>h2
.
Is there a way to copy that "path"?
When you select an element in the DOM inspector, that element becomes $0 in the console:
"Use $0 in the console to refer this element"
So you can simply go to the console and paste the following:
crumb = function(node) {
var idOrClass = (node.id && "#"+node.id) || (""+node.classList && (" "+node.classList).replace(/ /g, "."));
return node.tagName.toLowerCase() + idOrClass;};
crumbPath = function(node) {return node.parentNode ? crumbPath(node.parentNode).concat(crumb(node)) : [];};
crumbPath($0);
The output looks like this:
["html", "body.question-page.new-topbar", "div.container._full.", "div#content", "div", "div.inner-content.clearfix", "div#mainbar", "div#question", "div.post-layout", "div.postcell.post-layout--right", "div.post-text", "p"]
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With