HTML

[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>

 

결과보기



분류 제목
api HTML5 - Server-Sent Event - 서버전송이벤트 (= 서버센트이벤트)
etc HTML - 키보드 단축키 모음 (Window/Mac)
attribute HTML - lang 속성 ★ - 언어코드 (Language Code) + 국가코드 (Country Code…
etc HTML - 인터넷 (에러/오류) 의미 = (인터넷에러/인터넷오류) 종류 ★★★ + 500 Internal …
intro HTML - HTML5 사용조건 / HTML4.01과 다른점 (= HTML5 vs HTML401 차이점)
intro HTML - block요소 vs inline요소 ★★★★★ - (블락요소/블럭요소/블록요소 vs 인라인요소…
intro HTML - (Ctrl+U: 페이지 소스보기 HTML) vs (F12키: 개발자도구 요소검사 HTML) 차이…
etc HTML - 요소 클릭 안되는 경우 (= a태그 클릭 불가능 에러 원인/이유 = 클릭 실패/에러/장애 케이스…
etc HTML - inputmode 전역속성 - 사용자 입력값 데이터타입 힌트 (= inputmode속성 = 인풋…
intro HTML - (경로/주소) ★★★★★ - (절대경로/상대경로)/(절대주소/상대주소) 뜻/의미/개념/정의
etc HTML - Entity (= 태그 실체값 = 특수문자/기호 실질값 = 독립체)
basic HTML - <hgroup> 태그 - <h1>~<h6> 제목 묶기 (= 제목그룹 = hgroup태그 = 에이…
basic HTML - &nbsp; 기호 - 줄바꿈 않는 공백/빈칸 표시 특수문자 (= 공백기호/빈칸기호 = Non-B… 1
attribute HTML - accept 속성 ★ - 파일 업로드 시, 서버가 허용하는 파일 유형 지정 (= accept속성…
attribute HTML - accept-charset 속성 - FORM 제출에 사용할 문자 인코딩 지정 (= accept-…
10/24
목록
 홈  PC버전 로그인 일본어
그누앞단언어
그누뒷단언어
그외코딩언어
그누보드
제작의뢰
Q&A
커뮤니티
웹유틸
회원센터
홈짱닷컴 PC버전 로그인