Notice
Recent Posts
Recent Comments
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

DeFacto-Standard IT

[JQuery] attr() / prop() 본문

JavaScript/JQuery

[JQuery] attr() / prop()

defacto standard 2017. 11. 16. 20:59

.attr() - HTML의 속성(attribute)을 취급

.prop() - JavaScript의 property를 취급

 

예를들어

 

<a id="to_comments" href="#comments">클릭</a> 라는 element에 대해

var $link = $('#to_comments');

 

alert($link.attr('href')); -> 결과 #to_comment

alert($link.prop('href')); -> 결과 http://example.com/path/to/page#to_comment

 

'JavaScript > JQuery' 카테고리의 다른 글

[JQuery] html() / text() / val()  (0) 2017.11.16
Comments