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 fragment = new DocumentFragment(); for(let i = 1; i <= 5; i++) { let li = document.createElement('li'); li.append(i); fragment.append(li); } return fragment; } ul.append(getListContent()); // (*) </script> </body> </html>