jquery新版本旧版本之间的坑

JQuery自1.6.1版本开始增长一些属性,使用时尽可能使用这些新的属性,例如:selected、checked。在高版本中赋值时最好用prop,若是用attr就会出现赋值不成功的问题,web

通常自定义属性用attr,固有属性用propasync

如下是官方建议attr(),prop()的使用:spa

Attribute/Property .attr() .prop()
accesskey  
align  
async
autofocus
checked
class  
contenteditable  
draggable  
href  
id  
label  
location ( i.e. window.location )
multiple
readOnly
rel  
selected
src  
tabindex  
title  
type  
width ( if needed over .width() )
相关文章
相关标签/搜索