Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

앵코딩

1. selector (셀렉터) 본문

JavaScipt/codingapple

1. selector (셀렉터)

miaee 2023. 3. 26. 02:44

웹에서 JavaScript의 목적 : HTML의 조작과 변경

 

1. JS로 HTML조작하기

    <h2 id="hello">안녕하세요</h2>

    <script>
           // . ~의                HTML내용을 '안녕' 이라바꿈
      document.getElementById('hello').innerHTML = '안녕';
      //문서    아이디가 'hello'인 요소를 가져와서
      
                                    // 스타일의 color을 red로 바꿈
      document.getElementById('hello').style.color = 'red';
    </script>

* 모든 프로그래밍 언어에서 =대입연산자
컴퓨터는 정확하게 명령하여야 작동

 


숙제

위 안녕하세요 의 글자 사이즈를 30px로 바꾸기

 <h2 id="hello">안녕하세요</h2>
 
   <script>
        // 안녕하세요의 글자사이즈를 30px로 변경하기
    document.getElementById('hello').style.fontSize = '30px';
    </script>

 

'JavaScipt > codingapple' 카테고리의 다른 글

6. 서브메뉴 만들기, class List  (0) 2023.04.09
5. addEventListner()  (0) 2023.04.09
4. 파라미터  (0) 2023.04.09
3.Function  (0) 2023.03.26
2. Alert  (0) 2023.03.26
Comments