+ 1
Help JavaScript
textEdit.write("text") must create new paragraph with text and show it but why it doesn't? https://code.sololearn.com/W3h326EcyUrF/?ref=app
4 Answers
+ 3
CodeCat_ document.body no need id
+ 2
firstly you need to appendChild
secondly you need window.onload because scripts in JS tab goes to <head> so at that moment there is no <body> yet
https://code.sololearn.com/W6mU02g5RHia/?ref=app
+ 1
<!-- Something like this?? -->
<html>
<body id="bd"> </body>
</html>
<script>
window.onload = () => {
var textEdit = (function(text){
let e = document.createElement("p");
document.getElementById("bd").appendChild(e);
e.appendChild(text);
})(document.createTextNode("test"));
}
</script>
0
Okay, thanks u all