Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to create an anchor tag in javascript

//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)
 
PREVIOUS NEXT
Tagged: #create #anchor #tag #javascript
ADD COMMENT
Topic
Name
8+7 =