up
This commit is contained in:
parent
4272b7bb13
commit
508969c13f
168 changed files with 340 additions and 10 deletions
|
@ -0,0 +1 @@
|
|||
Please note using `textContent` to assign the `<li>` content.
|
24
2-ui/1-document/07-modifying-document/6-create-list/solution.view/index.html
Executable file
24
2-ui/1-document/07-modifying-document/6-create-list/solution.view/index.html
Executable file
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<body>
|
||||
<h1>Create a list</h1>
|
||||
|
||||
<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>
|
||||
|
||||
</body>
|
||||
</html>
|
19
2-ui/1-document/07-modifying-document/6-create-list/task.md
Normal file
19
2-ui/1-document/07-modifying-document/6-create-list/task.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
importance: 4
|
||||
|
||||
---
|
||||
|
||||
# Create a list
|
||||
|
||||
Write an interface to create a list from user input.
|
||||
|
||||
For every list item:
|
||||
|
||||
1. Ask a user about its content using `prompt`.
|
||||
2. Create the `<li>` with it and add it to `<ul>`.
|
||||
3. Continue until the user cancels the input (by pressing `key:Esc` or CANCEL in prompt).
|
||||
|
||||
All elements should be created dynamically.
|
||||
|
||||
If a user types HTML-tags, they should be treated like a text.
|
||||
|
||||
[demo src="solution"]
|
Loading…
Add table
Add a link
Reference in a new issue