Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>(any element).onclick(function() { uniqueSelector = $(this).getUniqueSelector(); }) </code></pre> <p><code>this</code> <strong>IS</strong> the unique selector and path to that clicked element. Why not use that? You can utilise jquery's <code>$.data()</code> method to set the jquery selector. Alternatively just push the elements you need to use in the future:</p> <pre><code>var elements = []; (any element).onclick(function() { elements.push(this); }) </code></pre> <hr> <p>If you really need the xpath, you can calculate it using the following code:</p> <pre><code> function getXPath(node, path) { path = path || []; if(node.parentNode) { path = getXPath(node.parentNode, path); } if(node.previousSibling) { var count = 1; var sibling = node.previousSibling do { if(sibling.nodeType == 1 &amp;&amp; sibling.nodeName == node.nodeName) {count++;} sibling = sibling.previousSibling; } while(sibling); if(count == 1) {count = null;} } else if(node.nextSibling) { var sibling = node.nextSibling; do { if(sibling.nodeType == 1 &amp;&amp; sibling.nodeName == node.nodeName) { var count = 1; sibling = null; } else { var count = null; sibling = sibling.previousSibling; } } while(sibling); } if(node.nodeType == 1) { path.push(node.nodeName.toLowerCase() + (node.id ? "[@id='"+node.id+"']" : count &gt; 0 ? "["+count+"]" : '')); } return path; }; </code></pre> <p>Reference: <a href="http://snippets.dzone.com/posts/show/4349" rel="noreferrer">http://snippets.dzone.com/posts/show/4349</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload