I created this FIDDLE as a test.
I have this li
inside a variable and I want to add the class c2
to that same li
var linha = '<li id= "id1" class="c1"> ' +
'<div id="id2">1</div>' +
'<div id="id3">2</div></li>'
document.getElementById('id1').addClass('c2');
My problem is that document.getElementById('id1')
always gives me NULL and then when I try to add the class it gives me the error: