My quickie one-liner:
$.fn.getPath = function(){
  return $.map (this.add(this.parents()), function(el) {
    return el.tagName + (el.className ? '.'+el.className : '');
  }).reverse().join(' > ');
}


On Apr 27, 6:59 am, "Alexandre Plennevaux" <[EMAIL PROTECTED]>
wrote:
> hello!
>
> i would like to know if there is a way to have jquery tell you what is the 
> DOM path to an element. For example:
>
> $(this).click(function(){
> alert($(this).getPath();
>
> });
>
> which would output
>
> html > body > div.col > ul.menu > li > a.selected
>
> ??
>
> thank you!!
>
> alex
>
> Alexandre Plennevaux - LAb[au] asbl.vzw / MediaRuimte
> Lakensestraat/Rue de Laeken 104
> B-1000 Brussel-Bruxelles-Brussels
> Belgie-Belgique-Belgium
>
> Tel:+32(0)2.219.65.55
> Fax:+32(0)2.426.69.86
> Mobile:+32(0)476.23.21.42
> HYPERLINK "blocked::http://www.lab-au.com/"http://www.lab-au.com
> HYPERLINK "blocked::http://www.mediaruimte.be/"http://www.mediaruimte.be
>
> HYPERLINK 
> "blocked::http://www.mediaruimte.be/"__________________________________________________________________________
>
> The information in this e-mail is intended only for the addressee named 
> above.  If you are not that addressee, please note that any disclosure, 
> distribution or copying of this e-mail is prohibited.
> Because e-mail can be electronically altered, the integrity of this 
> communication cannot be guaranteed.
>
> __________________________________________________________________________
>
> Ce message Envoi est certifié sans virus connu.
> Analyse effectuée par AVG.
> Version: 7.5.467 / Base de données virus: 269.6.1/777 - Date: 26/04/2007 15:23

Reply via email to