prop() 메서드

prop() 메서드

객체 조작 및 생성

$(function( ){

var result_1 = $("#chk1").prop("checked"); //id값이 "chk1"인 요소가 체크된 상태이면 true를 반환하여 result_1에 저장한다.

console.log(result_1); //false

var result_2 = $("#chk2").prop("checked");

console.log(result_2); // true

var result_2 = $("#chk3").prop("checked", true); // id값이 "chk3"인 요소의 체크상태를 true로 바꿔준다.

var result_3 = $("#se_1").prop("selectedIndex"); //id 값이 "se_1"인 요소의 옵션 중 selected 옵션의 인덱스값을 가져온다.

console.log(result_3); //2

});

객체 조작 및 생성

chk1

chk2

chk3

option1

option2

option3

from http://data05.tistory.com/155 by ccl(A) rewrite - 2021-08-21 14:26:49