2011-11-13 24 views

risposta

27

Certo:

$("#linkId").attr("href", "http://the.new.url"); 
0

Sì.

<script> 
$(function() { 
    $("#id_of_link").attr("href", "/new/url"); 
}); 
</script> 
16

Se il formato HTML è stato così:

<a href="xxx" id="myLink">whatever</a> 

È possibile modificare il collegamento facendo questo in javascript pianura:

document.getElementById("myLink").href = "http://whatever.com/yyyy"; 

Oppure, utilizzando jQuery:

$("#myLink").attr("href", "http://whatever.com/yyyy"); 
0

Se si desidera eseguire questa operazione quando la pagina l oads, utilizzare il seguente codice

$(document).ready(function() { 

$("#linkId").attr("href", "http://the.new.url"); 

}); 
Problemi correlati