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

home2 게시판 JavaScript, TS 게시판 자바스크립트로 html 생성하는 법 질문있습니다

자바스크립트로 html 생성하는 법 질문있습니다

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

    이창민
    참가자
    하기와같이 코딩했는데 바지사이즈가 그대로 95 100으로 나옵니다 ㅠㅠ
    어디서 틀렸는지 아무리봐도 안보입니다 ㅠㅠ 살려주세요
    추가로 append, appendchild 차이점이 궁금합니다
    <form class="container my-5 form-group">
    <p>상품선택</p>
    <select class="form-select mt-2">
    <option>모자</option>
    <option>셔츠</option>
    <option>바지</option>
    </select>
    <select id="option-shirt" class="form-select mt-2 hide">
    <option>95</option>
    <option>100</option>
    </select>
    </form>
    ---------------------
    
    $('.form-select').eq(0).on('input', function(){
    if(document.getElementsByClassName('form-select mt-2')[0].value == '셔츠'){
    document.getElementById('option-shirt').classList.remove('hide')
    } else if(
    document.getElementsByClassName('form-select mt-2')[0].value =='바지'){
    //바지 옵션창 띄워주세요
    document.getElementById('option-shirt').classList.remove('hide');
    document.getElementById('option-shirt').innerHTML('');
    var 템플릿 = `<option>28</option>
    <option>30</option>`;
    document.getElementById('option-shirt').append(템플릿);
    } else {
    document.getElementById('option-shirt').classList.add('hide')
    }
    #49299

    codingapple
    키 마스터
    쌩자바스크립트로 찾은 요소는 .append말고 .insertAdjacentHTML 이런거 써야합니다 
    appendChild()는 createElement() 이런걸로 만든 html 집어넣고싶을 때 씁니다 
    
2 글 보임 - 1 에서 2 까지 (총 2 중에서)
  • 답변은 로그인 후 가능합니다.

About

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

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

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