How to change the href for a hyperlink with jQuery
In this tutorial, we are going to see how to change the href for a hyperlink with jQuery. If you want to change the value of the href attribute using JQuery, you can use attr or prop functions depending on the version of JQuery being used.
If you are using JQuery 1.5 or lower, use the attr function:
$("a").attr("href", "https://stackhowto.com/");
If you are using JQuery 1.6 or higher, use the prop function:
$("a").prop("href", "https://stackhowto.com/");
The difference between prop and attr is that attr grabs the HTML attribute, while prop grabs the DOM property.
[st_adsense]