dimanche 6 septembre 2020

When Should you Write a link in JS than in HTML?

I was wondering if it's better to setup up writing links via JavaScript, or simple write it in your HTML page.

e.g. via JS

const btn = document.querySelector(".btn");

btn.setAttribute("href", "[url]");

e.g. via HTML

<a href="[url]"></a>

In what context would it be better to do one over the other method?




Aucun commentaire:

Enregistrer un commentaire