Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我得到一个 URL 作为输入,我想将它分配给一个锚标记。
假设网址是
var url = "http://www.google.com";
我想把这个网址像这样
<a href="http://www.google.com">http://www.google.com</a>
文档.createElement
var a = document.createElement('a'); a.href = "http://google.com"; a.textContent = a.href