3
I created this fiddle as a test.
I have this li
within a variable and I intend to add the class c2
to that very 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 the document.getElementById('id1')
always give me NULL and then when I try to add class gives me the error:
Returns
null
because theli
is only in a variable and not in the DOM.– Franchesco
@Earendul is there any way to catch the
li
being in a variable?– msm.oliveira
where jquery comes into this?
– Daniel Omine
why then does not modify directly in the variable ?
– Daniel Omine
example: line = '<li id= "id1" class="C2"> ' +
– Daniel Omine
because this was a small example to exemplify my problem
– msm.oliveira