Skip to content

Given a DOM node, return a unique CSS selector matching only that element

Notifications You must be signed in to change notification settings

joshwnj/unique-selector

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unique-selector

Build Status

Given a DOM node, return a unique CSS selector matching only that element. This is particularly useful when tracking in custom variables in analytics:

document.addEventListener('click', function(event) {
    var selector = unique(event.target);

    _gaq.push(['_trackEvent', 'Engagement', 'Click', selector]);
}, false);

Installation

component install ericclemmons/unique-selector

Tests

$ npm install
$ make
$ open test/index.html

Releases

  • v0.0.3

    • Add support for various <form> elements (#2)
  • v0.0.2

    • Fix bug with nth-child calculation
  • v0.0.1

    • Initial release

License

MIT

Bitdeli Badge

About

Given a DOM node, return a unique CSS selector matching only that element

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%