• 로그인
  • 장바구니에 상품이 없습니다.

home2 게시판 JavaScript, TS 게시판 자스 기초 질문드립니다 ㅠㅠ

자스 기초 질문드립니다 ㅠㅠ

3 글 보임 - 1 에서 3 까지 (총 3 중에서)
  • 글쓴이
  • #42964

    이창민
    참가자
    하기와같이 코딩시 맨 밑에 띄우기버튼을 누르면 모든 박스가 다 보이도록 하고싶은데
    저렇게 코딩하면 에러가 뜹니다 ㅠㅠ 다른방법이 있을까요?
     
    <!DOCTYPE html>
    <html>
    <head>
    <title>Parcel Sandbox</title>
    <meta charset="UTF-8" />
    <link href="src/styles.css" rel="stylesheet" />
    </head>
    <body>
    <div class="box1 box" id="box1">
    <p>box 1</p>
    <button onclick="document.getElementById('box1').style.display='none';">
     X
    </button>
    </div>
    <div class="box2 box" id="box2">
    <p>box 2</p>
    <button onclick="document.getElementById('box2').style.display='none';">
     X
    </button>
    </div>
    <div class="box3 box" id="box3">
    <p>box 3</p>
    <button onclick="document.getElementById('box3').style.display='none';">
     X
    </button>
    </div>
    <button
    onclick="document.getElementsByClassName('box').style.display='flex';"
     >
     띄우기
    </button>
    </body>
    </html>
    -------------------------------------------------------------------------------
    body {
    font-family: sans-serif;
    }
    .box1 {
    background-color: red;
    display: flex;
    justify-content: space-between;
    }
    .box2 {
    background-color: blue;
    display: flex;
    justify-content: space-between;
    }
    .box3 {
    background-color: green;
    display: flex;
    justify-content: space-between;
    }
     
     
    #42982

    이창민
    참가자
    하기와같이 노가다? 했는데 이렇게하는것도 방법이 맞는걸까욤..
    
    
    <button
    onclick="document.getElementById('box1').style.display='flex';
           document.getElementById('box2').style.display='flex';
           document.getElementById('box3').style.display='flex';"
     >
     띄우기
    </button>
    #43006

    codingapple
    키 마스터
    맞는방법입니다 이벤트리스너 써도 됩니다
3 글 보임 - 1 에서 3 까지 (총 3 중에서)
  • 답변은 로그인 후 가능합니다.

About

현재 월 700명 신규수강중입니다.

  (09:00~20:00) 빠른 상담은 카톡 플러스친구 코딩애플 (링크)
  admin@codingapple.com
  이용약관
ⓒ Codingapple, 강의 예제, 영상 복제 금지
top

© Codingapple, All rights reserved. 슈퍼로켓 에듀케이션 / 서울특별시 강동구 고덕로 19길 30 / 사업자등록번호 : 212-26-14752 온라인 교육학원업 / 통신판매업신고번호 : 제 2017-서울강동-0002 호 / 개인정보관리자 : 박종흠