U
uoL
Hello !
Anybody knows why this function doesn't work ? i'ts really simple I
create a p element and try to append a text element. The only thing
that work is appending a text element to de document element. then
nothing
function addtext(what){
var theNewParagraph = document.createElement('p');
var theTextOfTheParagraph = document.createTextNode('Some content.');
theNewParagraph.appendChild(theTextOfTheParagraph);
}
Note: if I create the element div on the document and then refer to it
like this :
function addtext(what){
var theNewParagraph = document.createElement('p');
var theTextOfTheParagraph = document.createTextNode('Some content.');
document.getElementById('someElementId').appendChild(theNewParagraph);
}
it works fine.
Thanks !
Regards,
uoL
Anybody knows why this function doesn't work ? i'ts really simple I
create a p element and try to append a text element. The only thing
that work is appending a text element to de document element. then
nothing
function addtext(what){
var theNewParagraph = document.createElement('p');
var theTextOfTheParagraph = document.createTextNode('Some content.');
theNewParagraph.appendChild(theTextOfTheParagraph);
}
Note: if I create the element div on the document and then refer to it
like this :
function addtext(what){
var theNewParagraph = document.createElement('p');
var theTextOfTheParagraph = document.createTextNode('Some content.');
document.getElementById('someElementId').appendChild(theNewParagraph);
}
it works fine.
Thanks !
Regards,
uoL