I was told this was not “proper”, I did not worry about it until I started getting a run-time error in IE9. Here is the code I need converted to use object properties.
Why is innerHTML not considered best practice?
var c=document.createElement('div');
c.innerHTML= '<a name="a1" class="b" href="' + d[2].value + '">' + d[1].value + '</a>';
It’s strange that you’re putting an
Aelement inside anAelement but the below should work.This assumes that
d[1].valueis not known to be well formed HTML from a trusted source so it is likely to be more robust against XSS than theinnerHTMLcode.