Skip to content

Instantly share code, notes, and snippets.

@BBonifield
BBonifield / make-selector.js
Created November 1, 2011 22:24 — forked from weaver/make-selector.js
Create an absolute jQuery selector for a DOM element.
// Create an absolute jQuery selector for a DOM element.
//
// + el - Element to select.
//
// Returns String selector.
function makeSelector(el) {
var tag, index, stack = [];
for (; el.parentNode; el = el.parentNode) {
tag = el.tagName;