首页 > Web开发 > 详细

jQuery .attr("checked")得undefined 问题解决

时间:2016-03-24 10:00:21      阅读:253      评论:0      收藏:0      [点我收藏+]

出现此错误是因为JQuery版本升级的问题。所以此处应该使用.prop();

那么,什么时候使用attr(),什么时候使用prop()?
1.添加属性名称该属性就会生效应该使用prop();
2.是有true,false两个属性使用prop();
3.其他则使用attr();
项目中jquery升级的时候大家要注意这点!

以下是官方建议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() ) √  

jQuery .attr("checked")得undefined 问题解决

原文:http://www.cnblogs.com/pocn/p/5314084.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!