<HTML>
<body>
<h1>Create a list</h1>
</body>
<script>
let ul = document.createElement('ul');
document.body.append(ul);
while(true){
let data = prompt("Enter the text for the list item", "");
if(!data) break;
let li = document.createElement('li');
li.textContent = data;
ul.append(li);
}
</script>
</HTML>
<body>
<h1>Create a list</h1>
</body>
<script>
let ul = document.createElement('ul');
document.body.append(ul);
while(true){
let data = prompt("Enter the text for the list item", "");
if(!data) break;
let li = document.createElement('li');
li.textContent = data;
ul.append(li);
}
</script>
</HTML>
/*
in the script it creates the ul
and make a li items by each user input and append it to ul every while run
i tried to use fragment to make it but it was simpler without it
yes the code is from the solution not from me
so what
¯\_(ツ)_/¯
*/
댓글
댓글 쓰기