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

[attribute] HTML - checked 속성 ★ - 미리 (체크박스/라디오) 체크 여부 지정 (= checked속성 = 체크트속성)

목차
  1. checked 예제 - <input type="checkbox"> 경우
  2. checked 정의
  3. checked 구문
  4. checked 예제 - <input type="radio"> 경우
  5. checked 예제 - 페이지 로드 완료 후, JS로 체크 적용

 

checked 예제 - <input type="checkbox"> 경우

 

<form action="/action_page.php" method="get">

  <input type="checkbox" name="html" value="html">

  <label for="html"> HTML</label><br>

  <input type="checkbox" name="css" value="css">

  <label for="css"> CSS</label><br>

  <input type="checkbox" name="js" value="js" checked>

  <label for="js"> JS</label><br><br>

  <input type="submit" value="확인">

</form>

 

결과보기

 

checked 정의

 

페이지 로드 시, (체크박스/라디오)가 미리 선택되어 있어야 하는지 지정하는 참거짓 속성.

 


 

1. checked 속성 사용 가능 태그

<input type="checkbox">, <input type="radio">

 

2.

JS 이용해, 페이지 로드 완료 후 지정도 가능.

 

3.

모든 브라우저 지원.

 

 

checked 구문

 

  • <input type="checkbox" checked>
  • <input type="radio" checked>

 


[속성값]

 

없음.

 

 

checked 예제 - <input type="radio"> 경우

 

<form action="/action_page.php" method="get">

  <input type="radio" id="html" name="html" value="html">

  <label for="html"> HTML</label><br>

  <input type="radio" id="css" name="css" value="css">

  <label for="css"> CSS</label><br>

  <input type="radio" id="js" name="js" value="js" checked>

  <label for="js"> JS</label><br><br>

  <input type="submit" value="확인">

</form>

 

결과보기

 

checked 예제 - 페이지 로드 완료 후, JS로 체크 적용

 

<form action="/action_page.php" method="get">

  <input type="radio" id="html" name="html" value="html">

  <label for="html"> HTML</label><br>

  <input type="radio" id="css" name="css" value="css">

  <label for="css"> CSS</label><br>

  <input type="radio" id="js" name="js" value="js">

  <label for="js"> JS</label><br><br>

  <input type="submit" value="확인">

</form>


<script>

window.addEventListener('DOMContentLoaded', function() {

    document.getElementById('js').checked = true;

});

</script>

 

결과보기



분류 제목
basic HTML - <html> 태그 ★ - HTML문서 (= html태그/html요소 = 에이치티엠엘태그/에이치티…
frame HTML - <frame> 태그 - 프레임셋안 개별프레임창 (HTML5제외)
media HTML - <source> 태그 - 미디어소스 불러오기 (= source태그 = 소스태그)
table HTML - <tfoot> 태그 - 테이블꼬릿말그룹 (= 테이블풋 = tfoot 태그 = 티풋태그) (HTM…
responsive HTML - Responsive Web Design (반응형 웹디자인) 장단점 + 홈페이지 제작법
style HTML - <footer> 태그 ★ - 단락꼬릿말 (= footer태그 = footer요소 = 푸터태그 =…
formatting HTML - <blockquote> 태그 ★ - 긴 인용구 (= blockquote태그 = blockquot…
link HTML - <nav> 태그 ★ - 네비게이션링크모음 (= nav태그 = 네브태그)
table HTML - <tbody> 태그 - 테이블셀그룹 (= 테이블바디 = tbody태그 = 티바디태그) (HTML…
formatting HTML - <ins> 태그 - 텍스트삽입표시 (= ins태그 = 인스태그 = 삽입태그)
formatting HTML - <cite> 태그 - 인용구 제목 (= cite태그 = cite요소 = 저작물제목 = 인용태그 …
formatting HTML - <bdo> 태그 - 텍스트출력방향 (= bdo태그 = bdo요소 = 글자방향 = 브도태그 = …
form HTML - <fieldset> 태그 ★ - 폼양식 관련요소묶음 (= fieldset태그 = 필드셋태그) (…
font HTML - <big> 태그 - 큰글씨 (= big태그 = big요소 = 큰글자 = 글자 크게 = 빅태그)…
formatting HTML - <var> 태그 - 변수정의 (= 변수태그 = var태그 = 바태그)
attribute HTML - Global Attribute - 전역속성 종류
form HTML - <output> 태그 - 계산 결과값 출력 (= output태그 = 아웃풋태그)
programming HTML - <object> 태그 - 미디어삽입 (= object태그 = 어브젝트태그)
api HTML5 - Server-Sent Event - 서버전송이벤트 (= 서버센트이벤트)
intro HTML - 태그 문법 ★
14/18
목록
찾아주셔서 감사합니다. Since 2012