• 회원가입
  • 로그인
  • 구글아이디로 로그인

[Statement] JS - switch 조건문 ★ (= switch문 = 스위치문)

switch 예제

 

<input id="code" type="text">


<button onclick="homzzang()">클릭</button>


<p id="demo"></p>


<script>

function homzzang() {

  var text;

  var codes = document.getElementById("code").value;


  switch(codes) {

    case "HTML":  text = "홈페이지 기본틀";  break;

    case "CSS":    text = "홈페이지 디자인";  break;

    case "JS":      text = "홈페이지 동작기능";  break;

    default:         text = "홈짱닷컴 Homzzang.com";

  }

  document.getElementById("demo").innerHTML = text;

}

</script>

 

결과보기

 

방문 감사합니다. (즐겨찾기 등록: Ctrl + D)

분류 제목
Statement JS - 구문 (Statements)
Statement JS - break 구문 ★ (= break문 = 브레이크문)
Statement JS - continue 구문 ★ (= continue문 = 컨티뉴문)
Statement JS - debugger 구문 (= debugger문 = 디버거문)
Statement JS - do ... while 구문 (= 두와일구문 = 두와일문 = 두와일반복문)
Statement JS - for 구문 (= for문 = 포구문 = 포문 = 포반복문)
Statement JS - for...in 구문 (= 포인구문 = 포인문 = 포인반복문)
Statement JS - function 구문 (= 함수구문)
Statement JS - if ... else if ... else ... 구문 (= if문 = 이프문 = 이프조건문)
Statement JS - return 구문 ★★ (= return문 = return구문 = 리턴문 = 반환문 = 리턴구문)…
Statement JS - switch 조건문 ★ (= switch문 = 스위치문)
Statement JS - throw 구문 (= 쓰로우문 = 쓰로우구문)
Statement JS - try ... catch ... finally 구문 (= 트라이캐치파이널구문)
Statement JS - var 구문 (= 변수정의)
Statement JS - while 구문 (= 와일문 = 와일반복문)
Statement JS - for...of 반복문 - 반복 가능 객체의 각 요소애 대해 반복 실행 (= 포어브반복문)
목록
찾아주셔서 감사합니다. Since 2012