I've done a function like this:
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(){
console.log( breadcrumbs(this) );
});
On 9/9/07, Richard D. Worth <[EMAIL PROTECTED]> wrote:
>
> Something like this?
>
> $('#myDiv').click(function() {
> var path = [this.tagName + '#' + this.id];
> $(this).parents().each(function() {
> path[path.length] = this.tagName ;
> });
> alert(path.join(' < '));
> });
>
> - Richard
>
> On 9/8/07, howa <[EMAIL PROTECTED] > wrote:
> >
> >
> > When mouse over an object, say a DIV for simplicity, I can use JQuery
> > to get its absolute position in DOM tree,
> >
> > e.g.
> >
> > div#header < body < html
> >
> >
> >
> > Any idea?
> >
> >
>
--
Rafael Santos Sá :: webdeveloper
www.rafael-santos.com