jquery中prop()方法和attr()方法的区别浅析
来源:互联网 发布:ubuntu sd卡挂载 编辑:程序博客网 时间:2024/06/07 22:12
大家都知道有的浏览器只要写disabled,checked就可以了,而有的要写成disabled = "disabled",checked="checked",比如用attr("checked")获取checkbox的checked属性时选中的时候可以取到值,值为"checked"但没选中获取值就是undefined。
jq提供新的方法“prop”来获取这些属性,就是来解决这个问题的,以前我们使用attr获取checked属性时返回"checked"和"",现在使用prop方法获取属性则统一返回true和false。
那么,什么时候使用attr(),什么时候使用prop()?
1.添加属性名称该属性就会生效应该使用prop();
2.是有true,false两个属性使用prop();
3.其他则使用attr();
0 0
- jquery中prop()方法和attr()方法的区别浅析
- jquery中prop()方法和attr()方法的区别浅析
- jquery中prop()方法和attr()方法的区别浅析
- jquery中prop()方法和attr()方法的区别浅析
- jquery中prop()方法和attr()方法的区别浅析
- jquery中prop()方法和attr()方法的区别浅析
- jquery中prop()方法和attr()方法的区别浅析
- jquery中prop()方法和attr()方法的区别浅析
- jQuery中prop()方法和attr()方法的区别浅析
- jquery中prop()方法和attr()方法的区别浅析
- jquery中prop()方法和attr()方法的区别浅析
- jquery中prop()方法和attr()方法的区别浅析
- jquery中prop()方法和attr()方法的区别浅析
- jquery中prop()方法和attr()方法的区别浅析
- jquery中prop()方法和attr()方法的区别浅析
- jquery中prop()方法和attr()方法的区别浅析
- jquery中prop()方法和attr()方法的区别浅析
- 【16】jquery中prop()方法和attr()方法的区别浅析
- Android:Fragment
- aix 文件夹压缩
- 安装WinPython
- 有用的方法
- 二叉图(高级数据结构)
- jquery中prop()方法和attr()方法的区别浅析
- Abelian Period
- @Autowire注解与自动装配
- 制作北大青鸟视频宣传片列表页面
- 北大青鸟视频宣传片列表
- Abandoned country
- C++11 新特性
- 07上机练习4
- 谷歌的Gson消息传递数据格式封装及解析,跨平台必用知识