up
This commit is contained in:
parent
1f61c2ab1d
commit
af0ee2a49e
66 changed files with 12263 additions and 2059 deletions
|
@ -1,24 +1,21 @@
|
|||
Решение:
|
||||
The solution, step by step:
|
||||
|
||||
```html run
|
||||
<select>
|
||||
<option value="Rock">Рок</option>
|
||||
<option value="Blues" selected>Блюз</option>
|
||||
<select id="genres">
|
||||
<option value="rock">Rock</option>
|
||||
<option value="blues" selected>Blues</option>
|
||||
</select>
|
||||
|
||||
<script>
|
||||
var select = document.body.children[0];
|
||||
|
||||
// 1)
|
||||
var selectedOption = select.options[select.selectedIndex];
|
||||
let selectedOption = genres.options[select.selectedIndex];
|
||||
alert( selectedOption.value );
|
||||
|
||||
// 2)
|
||||
var newOption = new Option("Classic", "Классика");
|
||||
select.appendChild(newOption);
|
||||
let newOption = new Option("classic", "Classic");
|
||||
select.append(newOption);
|
||||
|
||||
// 3)
|
||||
newOption.selected = true;
|
||||
</script>
|
||||
```
|
||||
|
||||
|
|
|
@ -2,20 +2,19 @@ importance: 5
|
|||
|
||||
---
|
||||
|
||||
# Добавьте опцию к селекту
|
||||
# Add an option to select
|
||||
|
||||
Есть селект:
|
||||
There's a `<select>`:
|
||||
|
||||
```html
|
||||
<select>
|
||||
<option value="Rock">Рок</option>
|
||||
<option value="Blues" selected>Блюз</option>
|
||||
<select id="genres">
|
||||
<option value="rock">Rock</option>
|
||||
<option value="blues" selected>Blues</option>
|
||||
</select>
|
||||
```
|
||||
|
||||
При помощи JavaScript:
|
||||
|
||||
1. Выведите значение и текст текущей выбранной опции.
|
||||
2. Добавьте опцию: `<option value="Classic">Классика</option>`.
|
||||
3. Сделайте её выбранной.
|
||||
Use Javascript to:
|
||||
|
||||
1. Show the value and the text of the selected option.
|
||||
2. Add an option: `<option value="classic">Classic</option>`.
|
||||
3. Make it selected.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue