title: How to get css selector for an element using javascript?
body: <p>Is there any jQuery plugin or javascript code that returns a CSS-selector that uniquely selects a particular element?</p>
  
  <p>I'm looking for something with similar functionality as provided by the <em>Copy CSS Path</em> function in Chrome's developer tools, giving me a selector that looks something like this:</p>
  
  <pre><code>#question &gt; table &gt; tbody &gt; tr:nth-child(2) &gt; td &gt; div &gt; h2
  </code></pre>
  
  <p><strong>Answers I tried</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/5706837/get-unique-selector-of-element-in-jquery">Get unique selector of element in Jquery</a></p>
  
  <p><a href="https://stackoverflow.com/questions/15360991/get-unique-selector-jquery">Get unique selector jQuery</a></p>