문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
wiki:html:html_note:html_dom_getelementsbyclassname_method [2021/04/07 13:45] emblim98 |
wiki:html:html_note:html_dom_getelementsbyclassname_method [2023/01/13 18:44] (현재) |
||
|---|---|---|---|
| 줄 93: | 줄 93: | ||
| </ | </ | ||
| + | ====예제==== | ||
| + | %%HTMLCollection%% 오브젝트의 length 속성을 사용하여, | ||
| + | <code javascript> | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | <div class=" | ||
| + | A div element with class=" | ||
| + | </ | ||
| + | <div class=" | ||
| + | Another div element with class=" | ||
| + | </ | ||
| + | <p class=" | ||
| + | < | ||
| + | <button onclick=" | ||
| + | < | ||
| + | <p id=" | ||
| + | < | ||
| + | function myFunction() { | ||
| + | var x = document.getElementsByClassName(" | ||
| + | document.getElementById(" | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ====예제==== | ||
| + | %%class=" | ||
| + | <code javascript> | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | .example { | ||
| + | border: 1px solid #000; | ||
| + | margin: 5px; | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | <div class=" | ||
| + | A div with class=" | ||
| + | </ | ||
| + | <div class=" | ||
| + | Another div with class=" | ||
| + | </ | ||
| + | <p class=" | ||
| + | < | ||
| + | < | ||
| + | <button class=" | ||
| + | < | ||
| + | < | ||
| + | function myFunction() { | ||
| + | var x = document.getElementsByClassName(" | ||
| + | var i; | ||
| + | for (i = 0; i < x.length; i++) { | ||
| + | x[i].style.backgroundColor = " | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||