Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the Document</title> </head> <body> <ul id="ul"></ul> <script> function getListContent() { let result = []; for(let i = 1; i <= 5; i++) { let li = document.createElement('li'); li.append(i); result.push(li); } return result; } ul.append(...getListContent()); // append + "..." operator = friends! </script> </body> </html>