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

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

 

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() )  

相关文章:

  • 2021-10-22
  • 2021-11-20
  • 2021-06-06
  • 2022-12-23
  • 2021-10-25
  • 2022-01-19
  • 2022-01-17
猜你喜欢
  • 2021-09-15
  • 2021-05-24
  • 2021-06-16
  • 2021-10-03
  • 2021-07-28
  • 2021-09-26
  • 2021-10-20
相关资源
相似解决方案