Home  >  Article  >  Web Front-end  >  JavaScript and jquery modify the href attribute of a tag_jquery

JavaScript and jquery modify the href attribute of a tag_jquery

WBOY
WBOYOriginal
2016-05-16 17:08:491348browse

javascript:

Copy code The code is as follows:

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

jquery:
Copy code The code is as follows:

$("#myId").attr("href"," www.xxx.com");
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn