각 요소의 속성은 유용한 정보를 가지고 있기 때문에, 이것을 가지고 get/set 하는 것은 중요하다.
.attr() 메소드
.attr() 메소드로 getter/setter 작업 둘 다 할 수 있다.
.attr() setter:
1
2
3
4
5
6
7
8
9
10
11
12
13 |
$( "a" ).attr( "href", "allMyHrefsAreTheSameNow.html" );
$( "a" ).attr({
title: "all titles are the same too!",
href: "somethingNew.html"
});
|
cs |
.attr() getter:
1 |
$( "a" ).attr( "href" ); // Returns the href for the first a element in the document |
cs |
'3.자바스크립트 > jQuery' 카테고리의 다른 글
.css() 이용하여 버튼 보이지 않도록 하기 (0) | 2016.07.11 |
---|---|
jQuery 폼요소 선택하기 (Selecting Form Elements) (1) | 2016.05.23 |
jQuery 요소 선택하기 (0) | 2016.05.23 |