You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
그런데 폼 요소의 이름을 변경하는 일은 드물기 때문에 보통은 이런 특징이 문제가 되지 않습니다.
138
-
=======
139
-
That's usually not a problem, however, because we rarely change names of form elements.
140
-
>>>>>>> upstream/master
141
123
142
124
````
143
125
@@ -173,11 +155,7 @@ That's usually not a problem, however, because we rarely change names of form el
173
155
174
156
### input과 textarea
175
157
176
-
<<<<<<< HEAD
177
-
input과 textarea 요소의 값은 `input.value` (string) 또는 `input.checked`(boolean)을 사용해 얻을 수 있습니다.
178
-
=======
179
-
We can access their value as `input.value` (string) or `input.checked` (boolean) for checkboxes and radio buttons.
180
-
>>>>>>> upstream/master
158
+
input과 textarea 요소의 값은 `input.value` (string)로 얻을 수 있고, 체크박스와 라디오 버튼의 경우 `input.checked`(boolean)를 사용해 선택 여부를 확인할 수 있습니다.
181
159
182
160
이렇게 말이죠.
183
161
@@ -198,33 +176,17 @@ input.checked = true; // 체크박스나 라디오 버튼에서 쓸 수 있습
198
176
199
177
`<select>` 요소에는 세 가지 중요 프로퍼티가 있습니다.
200
178
201
-
<<<<<<< HEAD
202
179
1. `select.options` -- `<option>` 하위 요소를 담고 있는 컬렉션
203
-
2. `select.value` -- 현재 선택된 `<option>` 값
204
-
3. `select.selectedIndex` -- 현재 선택된 `<option>`의 번호(인덱스)
205
-
=======
206
-
1. `select.options` -- the collection of `<option>` subelements,
207
-
2. `select.value` -- the *value* of the currently selected `<option>`,
208
-
3. `select.selectedIndex` -- the *number* of the currently selected `<option>`.
209
-
>>>>>>> upstream/master
180
+
2. `select.value` -- 현재 선택된 `<option>` *값*
181
+
3. `select.selectedIndex` -- 현재 선택된 `<option>`의 *번호(인덱스)*
210
182
211
183
이 세 프로퍼티를 응용하면 아래와 같은 세 가지 방법으로 `<select>`의 값을 설정할 수 있습니다.
212
184
213
-
<<<<<<< HEAD
214
-
1. 조건에 맞는 `<option>` 하위 요소를 찾아 `option.selected`속성을 `true`로 설정합니다.
185
+
1. `select.options`등에서 조건에 맞는 `<option>` 요소를 찾아 `option.selected`속성을 `true`로 설정합니다.
215
186
2. `select.value`를 원하는 값으로 설정합니다.
216
187
3. `select.selectedIndex`를 원하는 option 번호로 설정합니다.
217
188
218
-
세 방법 중 첫 번째 방법이 가장 확실하지만 두 번째나 세 번째 방법이 대체로 더 편리합니다.
219
-
220
-
예시:
221
-
=======
222
-
1. Find the corresponding `<option>` element (e.g. among `select.options`) and set its `option.selected` to `true`.
223
-
2. If we know a new value: set `select.value` to the new value.
224
-
3. If we know the new option number: set `select.selectedIndex` to that number.
225
-
226
-
Here is an example of all three methods:
227
-
>>>>>>> upstream/master
189
+
세 가지 방법을 모두 사용한 예시를 살펴봅시다.
228
190
229
191
```html run
230
192
<select id="select">
@@ -234,30 +196,17 @@ Here is an example of all three methods:
234
196
</select>
235
197
236
198
<script>
237
-
<<<<<<< HEAD
238
199
// 세 가지 코드의 실행 결과는 모두 같습니다.
239
200
select.options[2].selected = true;
240
-
=======
241
-
// all three lines do the same thing
242
-
select.options[2].selected = true;
243
-
>>>>>>> upstream/master
244
201
select.selectedIndex = 2;
245
202
select.value = 'banana';
246
203
// please note: options start from zero, so index 2 means the 3rd option.
247
204
</script>
248
205
```
249
206
250
-
<<<<<<< HEAD
251
-
대부분의 다른 폼 조작 요소와 달리 `<select>`는 `multiple` 속성이 있는 경우 option을 다중 선택할 수 있습니다. `multiple` 속성을 쓰는 경우는 아주 드물지만, 쓰게 되다면 첫 번째 방법을 사용해 `<option>` 하위 요소에 있는 `selected` 프로퍼티를 추가·제거해야 합니다.
252
-
253
-
선택된 여러 개의 option이 담긴 컬렉션은 다음 예시처럼 `select.options`를 사용해 얻을 수 있습니다.
254
-
=======
255
-
Unlike most other controls, `<select>` allows to select multiple options at once if it has `multiple` attribute. This attribute is rarely used, though.
207
+
대부분의 다른 폼 조작 요소와 달리 `<select>`는 `multiple` 속성이 있는 경우 option을 다중 선택할 수 있습니다. `multiple` 속성을 쓰는 경우는 아주 드물지만, 쓰게 된다면 첫 번째 방법을 사용해 `<option>` 하위 요소에 있는 `selected` 프로퍼티를 추가·제거해야 합니다.
256
208
257
-
For multiple selected values, use the first way of setting values: add/remove the `selected` property from `<option>` subelements.
258
-
259
-
Here's an example of how to get selected values from a multi-select:
260
-
>>>>>>> upstream/master
209
+
선택된 여러 개의 option이 담긴 컬렉션은 다음 예시처럼 `select.options`를 사용해 얻을 수 있습니다.
261
210
262
211
```html run
263
212
<select id="select" *!*multiple*/!*>
@@ -280,51 +229,33 @@ Here's an example of how to get selected values from a multi-select:
280
229
281
230
### Option 생성자
282
231
283
-
<<<<<<<HEAD
284
-
Option 생성자는 잘 사용되지는 않지만 흥미로운 점이 있습니다.
285
-
286
-
[명세서](https://html.spec.whatwg.org/multipage/forms.html#the-option-element)를 보면 `<option>` 요소를 생성하는 간단하고 멋진 문법을 찾을 수 있죠.
287
-
=======
288
-
In the [specification](https://html.spec.whatwg.org/multipage/forms.html#the-option-element) there's a nice short syntax to create an `<option>` element:
289
-
>>>>>>> upstream/master
232
+
[명세서](https://html.spec.whatwg.org/multipage/forms.html#the-option-element)를 보면 `<option>` 요소를 생성하는 간단하고 멋진 문법을 찾을 수 있습니다.
290
233
291
234
```js
292
235
option = new Option(text, value, defaultSelected, selected);
293
236
```
294
237
295
-
<<<<<<<HEAD
238
+
이 문법은 선택 사항입니다. `document.createElement('option')`를 사용해 요소를 만들고 속성을 직접 설정해도 되지만, 이 문법을 사용하면 더 짧게 쓸 수 있습니다.
239
+
296
240
매개변수:
297
-
=======
298
-
This syntax is optional. We can use `document.createElement('option')` and set attributes manually. Still, it may be shorter, so here are the parameters:
299
-
>>>>>>> upstream/master
300
241
301
242
- `text` -- option 내부의 텍스트
302
243
- `value` -- option의 값
303
244
- `defaultSelected` -- `true`이면 HTML 속성 `selected`가 생성됨
304
245
- `selected` -- `true`이면 해당 option이 선택됨
305
246
306
-
<<<<<<<HEAD
307
-
`defaultSelected`와 `selected`의 차이가 무엇인지 헷갈릴 수 있습니다. `defaultSelected`는 `option.getAttribute('selected')`를 사용해 얻을 수 있는 HTML 속성을 설정해 줍니다. 반면 `selected` 는 option의 선택 여부를 결정합니다. 그렇기 때문에 당연히 `selected`가 더 중요한 매개변수이죠. Option 생성자를 사용할 때는 대개 두 매개변수 모두를 `true`나 `false`로 설정합니다.
247
+
`defaultSelected`와 `selected`의 차이가 무엇인지 헷갈릴 수 있습니다. `defaultSelected`는 `option.getAttribute('selected')`를 사용해 얻을 수 있는 HTML 속성을 설정해 줍니다. 반면 `selected` 는 option의 선택 여부를 결정합니다.
308
248
309
-
예시:
310
-
=======
311
-
The difference between `defaultSelected` and `selected` is that `defaultSelected` sets the HTML-attribute (that we can get using `option.getAttribute('selected')`), while`selected` sets whether the option is selected or not.
312
-
313
-
In practice, one should usually set _both_ values to `true` or `false`. (Or, simply omit them; both default to `false`.)
249
+
Option 생성자를 사용할 때는 대개 두 매개변수 _모두_ `true`나 `false`로 설정합니다. 둘 다 생략할 수 있고, 이때 기본값은 둘 다 `false`입니다.
314
250
315
-
For instance, here's a new "unselected" option:
316
-
>>>>>>> upstream/master
251
+
예를 들어 '선택되지 않은' 새 option은 다음과 같이 만들 수 있습니다.
317
252
318
253
```js
319
254
let option = new Option("Text", "value");
320
255
// <option value="value">Text</option> 가 생성됩니다.
321
256
```
322
257
323
-
<<<<<<< HEAD
324
-
이번엔 같은 요소를 선택된 상태로 생성합니다.
325
-
=======
326
-
The same option, but selected:
327
-
>>>>>>> upstream/master
258
+
이번엔 같은 요소를 선택된 상태로 생성해 봅시다.
328
259
329
260
```js
330
261
let option = new Option("Text", "value", true, true);
@@ -358,15 +289,9 @@ Option을 사용해 만든 요소에는 다음과 같은 프로퍼티가 있습
358
289
`element.form`
359
290
: 요소는 `form` 프로퍼티에서 자신이 속한 폼을 참조합니다.
360
291
361
-
<<<<<<< HEAD
362
-
각 요소의 값은 `input.value`, `textarea.value`, `select.value` 등으로 접근할 수 있습니다. 체크박스와 라디오 버튼에서는 `input.checked`를 사용할 수 있습니다.
363
-
364
-
`<select>`에서는 인덱스 `select.selectedIndex`나 option 컬렉션 `select.options`을 통해 값을 구할 수도 있습니다.
365
-
=======
366
-
Value is available as `input.value`, `textarea.value`, `select.value`, etc. (For checkboxes and radio buttons, use `input.checked` to determine whether a value is selected.)
292
+
각 요소의 값은 `input.value`, `textarea.value`, `select.value` 등으로 접근할 수 있습니다. 체크박스와 라디오 버튼에서는 값이 선택되었는지 확인하려면 `input.checked`를 사용합니다.
367
293
368
-
For `<select>`, one can also get the value by the index `select.selectedIndex` or through the options collection `select.options`.
369
-
>>>>>>> upstream/master
294
+
`<select>`에서는 인덱스 `select.selectedIndex`나 option 컬렉션 `select.options`를 통해 값을 구할 수도 있습니다.
370
295
371
296
지금까지는 폼 관련 기본을 다뤘습니다. 이 튜토리얼에서 앞으로 더 많은 예시를 만날 것입니다.
Copy file name to clipboardExpand all lines: 2-ui/4-forms-controls/2-focus-blur/4-edit-td-click/task.md
+1-8Lines changed: 1 addition & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,17 +6,10 @@ importance: 5
6
6
7
7
셀을 클릭하면 해당 셀을 수정할 수 있게 해주는 테이블을 만들어보세요.
8
8
9
-
<<<<<<< HEAD
10
-
- 셀 클릭 시 셀 안에 textarea가 나타나면서 셀에 들어 있는 콘텐츠(HTML)를 '수정'할 수 있어야 합니다. 이때 textarea 크기는 기존 cell 크기와 같아야 합니다.
9
+
- 셀 클릭 시 셀 안에 textarea가 나타나면서 셀에 들어 있는 콘텐츠(HTML)를 '수정'할 수 있어야 합니다. 이때 textarea 크기는 기존 cell 크기와 같아야 하며, 전체 배치가 그대로 유지되어야 합니다.
11
10
- 셀 수정 시 셀 아래쪽에 '완료'와 '취소' 버튼이 노출되도록 하고, 각 버튼을 누르면 수정이 종료, 취소될 수 있게 합니다.
12
11
- 한 번에 하나의 셀만 수정할 수 있어야 합니다. `<td>`가 '수정 중'일 때는 다른 셀을 눌러도 클릭 이벤트가 무시되어야 합니다.
13
12
- 테이블엔 더 많은 셀이 추가될 수 있으므로 이벤트 위임을 사용하세요.
14
-
=======
15
-
- On click -- the cell should become "editable" (textarea appears inside), we can change HTML. There should be no resize, all geometry should remain the same.
16
-
- Buttons OK and CANCEL appear below the cell to finish/cancel the editing.
17
-
- Only one cell may be editable at a moment. While a `<td>` is in "edit mode", clicks on other cells are ignored.
18
-
- The table may have many cells. Use event delegation.
0 commit comments