2010-07-31 15 views

risposta

46

Sì, è possibile. Faccio qualcosa di simile in uno dei miei siti, anche se con href anziché id, ma anche lo id funziona. Un rapido esempio:

$('a[id]').click(function(e) 
{ 
    // This will change the URL fragment. The change is reflected 
    // on your browser's address bar as well 
    window.location.hash = this.id; 
    e.preventDefault(); 
}); 
+0

Meraviglioso :-) Grazie mille! – circey

+0

È questo cross-browser? – jldupont

+0

@jldupont: dovrei pensarlo. – BoltClock

Problemi correlati