사용자 도구

사이트 도구


wiki:html:html_note:html_dom_getelementsbyclassname_method

문서의 이전 판입니다!


HTML DOM getElementsByClassName() Method

  • description : HTML DOM getElementsByClassName() Method
  • author : 오션
  • email : shlim@repia.com
  • lastupdate : 2021-04-07


Source of the article


지정 클래스 이름을 가진 모든 요소들을 가져옵니다.

예제

<!DOCTYPE html>
<html lang="en">
<body>
    <div class="example">First div element with class="example".</div>
    <div class="example">Second div element with class="example".</div>
    <p>Click the button to change the text of the first div element with class="example" (index 0).</p>
    <button onclick="myFunction()">Try it!</button>
    <p><strong>Note:</strong> The getElementsByClassName() method is not supported in Internet Explorer 8 and eralier versions.</p>
    <script>
        function myFunction() {
            var x = document.getElementsByClassName("example");
            x[0].innerHTML = "Hello World!";
        }
    </script>
</body>
</html>



/volume1/web/dokuwiki/data/attic/wiki/html/html_note/html_dom_getelementsbyclassname_method.1617768450.txt.gz · 마지막으로 수정됨: 2022/03/10 19:52 (바깥 편집)