Hello guys,
I’m just learning about HTML DOM and have the following question.
If you want to create something like: <a …><img …></a> with HTML DOM, then I believe you can do that in the following ways:
var newA = document.createElement(‘a’);
newA.innerHTML = “<img…>”;
or
var newA = document.createElement(‘a’);
var newI = document.createElement(‘img’);
newA.appendChild(newI);
I believe both codes will work, right? Which one is better to use? Any advantages/disadvantages when using one or the other?