JQuery 1.6의 가장 큰 변화! .prop() 함수.


  실제 프로젝트에서 jQuery를 적용중입니다. 기존 순수 Javascript를 사용할 때 보다 코드 양이 많이 줄어드는 것 때문에 저는 jQuery를 선호하는 편입니다. 그런데 1.4를 쓰다가 1.6대로 변경된 적이 있는데 이상하게 적용이 안되는 부분이 있었습니다.
  checkbox의 상태를 변경하거나 읽어올 때 '.attr()'함수를 이용했었는데 어느 순간부터인가 적용이 잘 안되었습니다. 단순 오류라고 생각하고
jObject[0].checked = "checked";
이렇게 javascript 객체로 변경해서 진행했습니다. (적용이 안되니 어떻게든 되게 해야져 ^^;;)
그런데 우연한 구글신과의 만남중에 정말로 우연히 1.6에서 변화가 있었다는 것을 알게되었습니다. 사용하고 있던 api가 이렇게 변경될 줄이야!!
  기존의 attr()로 처리되었던 것을 attr()과 prop()로 분리되어 처리되게 되었습니다.

.prop()
 


다음은 .attr()과 .prop()사용에 관한 구분입니다.
(출처:서디의 다락방:jQuery 1.6.1 릴리즈, 성능 , 버그 픽스 내용

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

저작자 표시

'Programming > jQuery' 카테고리의 다른 글

JQuery 1.6의 가장 큰 변화! .prop() 함수.  (7) 2011/12/20
  • 비밀댓글입니다

  • I’m a philosophy graduate who needs academic writing help throughout the week. I’ve been using some very high-priced custom writing services online until I found acceptable writing service where I could freely buy Comparison and contrast essay.

  • There are many various ways to get know about this good post . But I propose to buy custom essay papers and custom writing or already written essays choosing the perfect writing services.

  • Do you have a joyful life.

  • The best issue close to this good topic! I guess, that’s worth to buy essay to have a success!

  • To create the format thesis just about this good post is not effortless but you deal with this. When every writer is like, all people will never have got problems with the dissertation.

Write your message and submit