Javascript and jquery modify the href attribute of the a tag

  • 2020-03-30 00:55:01
  • OfStack

javascript :
 
document.getElementById("myId").setAttribute("href","www.xxx.com"); 
document.getElementById("myId").href = "www.xxx.com"; 

jquery:
 
$("#myId").attr("href","www.xxx.com"); 

Related articles: