I am letting user to take screenshot on div user clicking on from url, but how can I get css selector Ex.(#clients > div > div > div:nth-child(1)) to capture the screenshot.
using jquery how can I achieve that, please help me with that.
I am letting user to take screenshot on div user clicking on from url, but how can I get css selector Ex.(#clients > div > div > div:nth-child(1)) to capture the screenshot.
using jquery how can I achieve that, please help me with that.
I got the answer fot this using library which generates CSS selectors from DOM nodes jhartikainen/dompath and it easy to implement.
Just add dompath.js
script into your file.
USAGE :
e.target.contentDocument.body.addEventListener('click', e => {
targetSelector= '';
//call function, pass any element:
var csspath = dompath(e.target);
//get CSS selector:
targetSelector = csspath.toCSS();
console.log(targetSelector);
//#about > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > ul:nth-child(2) > li:nth-child(1)
});