📜  如何在 javascript 代码示例中创建锚标记

📅  最后修改于: 2022-03-11 15:01:38.542000             🧑  作者: Mango

代码示例1
//for adding a link through JavaScript 
let anchor=document.createElement("a");
anchor.href="_anylinkthatyouwanttoadd_";
anchor.innerText="Go to the above link";//optional
console.log(anchor)
let to_add=document.getElementById("the-id-of-the-element-where-you-want-to-add")
to_add.appendChild(anchor)