Oooh..that's a much harder problem than the one originally presented. jQuery supports the :nth-child() selector; you want a string that uniquely selects 'this' . The following ought to work: (function ($){
function toString(el){ console.log (el); var ret = el.tagName.toLowerCase(); if (el.id) ret += '#'+el.id; if (el.classname) ret += '.'+el.className.replace(/\s/g,'.'); if ($(el).siblings(el.tagName).length) ret += ':nth-child(' + ($ (el).prev().length+1) + ')'; return ret; } $.fn.getPath = function(){ return $.map (this, function(a){ return $.map ($(a).add($(a).parents()), toString).reverse().join(' > '); }).join(','); } })(jQuery); (It adds the ability to pass in more than one element; the paths will be separated by commas) On Apr 27, 2:20 pm, Ariel Jakobovits <[EMAIL PROTECTED]> wrote: > thats cool. But what if an element has no id or is not the only sibliing with > that class? you need to add its position within the parent in that case, > which is actually more useful. > > but, this is only only worth it if jQuery supports td:1 vs td:first which I'm > not sure it does.