0

Adding hyperlink to JavaScript

Have an ID on HTML file, e.g. apply. How can I add an hyperlink to the ID on JavaScript instead of amending the HTML?

20th Feb 2020, 4:05 PM
SWL
3 Respuestas
+ 2
document.getElementById('abc'). innerHTML = '<a href = "your_link">abc</a>';
20th Feb 2020, 4:13 PM
A͢J
A͢J - avatar
0
Thanks! But having this error “Uncaught TypeError: Cannot set property ‘innerHTML’ of null”, how can I debug?
21st Feb 2020, 3:53 PM
SWL
0
Use : onload=()=>{ // your code here }
24th Feb 2020, 10:32 PM
JS LOVER
JS LOVER - avatar