2011-11-13 14 views

Respuesta

27

Claro:

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

Sí.

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

Si su HTML fue así:

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

Puede cambiar el enlace al hacer esto en javascript claro:

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

O, usando jQuery:

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

Si desea hacer esto cuando la página l oads, utilice el siguiente código

$(document).ready(function() { 

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

}); 
Cuestiones relacionadas