关于jQuery中attr(),prop()的使用

注意:何时使用attr(),何时使用prop()?
1.添加属性名称该属性就会生效应该使用prop();
2.是有true,false两个属性使用prop();
3.其余则使用attr();async

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

 

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() )
相关文章
相关标签/搜索