+ 1
please answer
Drag and drop from the options below to add a new <li> element to the unordered list with id="list". var el = document.--createelement--("li"); var txt = document.createTextNode("B"); el.appendChild(txt); var ul = document.---getelementbyid-------("list"); ul.-----appendchild------(el);
3 Respostas
+ 3
Since they are just three blank spaces, you can easily try every possible combination. And when you "solved" it you can read the comments to understand better.
This is called brute force approach.
Here's the most upvoted explanation in the comments, but there are many more:
1. you create element (el="li")
2. then create text object (txt="B")
3. then append txt to el (<li>B</li>)
4. then you find and take a "list" as ul
5. and append el to ul (<ul id="list"><li>B</li></list>)
thats it!
+ 3
var el = document.createElement("li");
var txt = document.createTextNode("B");
el.appendChild(txt);
var ul = document.getElementById("list");
ul.appendChild(el);
+ 1
var el = document.createElement("li");
var txt = document.createTextNode("B");
el.appendChild(txt);
var ul = document.getElementById("list");
ul.appendChild(el);