Return to Snippet

Revision: 3737
at September 9, 2007 10:45 by fael


Initial Code
myId = function(me){ return me.id ? '#' + me.id : '' }
myTag = function(me){ return me.tagName ? me.tagName.toLowerCase() : '' }
myClass = function(me){ return me.className ? '.' + me.className.split(' ').join('.') : '' }

breadcrumbs = function(me){
  var path = [myTag(me) + myId(me) + myClass(me)];
  $(me).parents().each(function() {
          path[path.length] = myTag(this) + myId(this) + myClass(this);
  });
  return path.join(' < ');
}

$('body').click( function(){
  alert( breadcrumbs(this) );
});

Initial URL

                                

Initial Description
a function that returns the absolute position in DOM tree. jQuery based

Initial Title
element's absolute position in DOM Tree

Initial Tags
jquery

Initial Language
JavaScript