attr 은 HTML 속성관련, prop은 java script 관련 값이라는 차이가 있음 .
jquery 1.6 버전 이후로 변화가 있음.
elem.checked | true (Boolean) Will change with checkbox state |
---|---|
$(elem).prop("checked") | true (Boolean) Will change with checkbox state |
elem.getAttribute("checked") | "checked" (String) Initial state of the checkbox; does not change |
$(elem).attr("checked") (1.6) | "checked" (String) Initial state of the checkbox; does not change |
$(elem).attr("checked") (1.6.1+) | "checked" (String) Will change with checkbox state |
$(elem).attr("checked") (pre-1.6) | true (Boolean) Changed with checkbox state |
Attribute/Property | .attr() | .prop() | |
---|---|---|---|
accesskey | ✓ | ||
align | ✓ | ||
async | ✓ | ✓ | |
autofocus | ✓ | ✓ | |
checked | ✓ | ✓ | |
class | ✓ | ||
contenteditable | ✓ | ||
defaultValue | ✓ | ||
draggable | ✓ | ||
href | ✓ | ||
id | ✓ | ||
label | ✓ | ||
location * | ✓ | ✓ | |
multiple | ✓ | ✓ | |
nodeName | ✓ | ||
nodeType | ✓ | ||
readOnly | ✓ | ✓ | |
rel | ✓ | ||
selected | ✓ | ✓ | |
selectedIndex | ✓ | ||
src | ✓ | ||
style | ✓ | ||
tabindex | ✓ | ||
tagName | ✓ | ||
title | ✓ | ||
type | ✓ | ||
width ** | ✓ |
'AJAX, JQUERY, JAVASCRIPT' 카테고리의 다른 글
javascript 기본 (0) | 2013.07.01 |
---|---|
Jquery 기본 (0) | 2013.06.19 |
selector (0) | 2013.03.04 |
JQUERY (0) | 2013.03.04 |
Ajax_1 (0) | 2013.02.20 |