+ 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);

14th Nov 2020, 10:57 AM
ahmad iswdany
ahmad iswdany - avatar
3 Respuestas
+ 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!
14th Nov 2020, 11:07 AM
Davide
Davide - avatar
+ 3
var el = document.createElement("li"); var txt = document.createTextNode("B"); el.appendChild(txt); var ul = document.getElementById("list"); ul.appendChild(el);
9th Jun 2021, 12:42 AM
S M HARSHA MANOJ SURAWEERA
+ 1
var el = document.createElement("li"); var txt = document.createTextNode("B"); el.appendChild(txt); var ul = document.getElementById("list"); ul.appendChild(el);
7th Dec 2021, 11:21 AM
Md. Rakibul Islam
Md. Rakibul Islam - avatar