jQuery的prop和attr方法之间区别
来源:互联网 发布:打印出库单软件 编辑:程序博客网 时间:2024/06/05 00:37
JQuery.attr():
Get the value of an attribute for the first element in the set of matched elements.
JQuery. Prop():
Gets the value of a property for the first element in the set of matched elements.
Reference MSDN:
for a checkbox (jquery 1.6+)
<input id="check1" checked="checked" type="checkbox" />
.attr('checked') //returns checked
.prop('checked') //returns true
.is(':checked') //returns true
Prop() method returns Boolean value for checked, selected, disabled, readOnly..and so on while attr returns defined string. So, you can directly use .prop("checked") in if condition. SelectedIndex, tagName, nodeName, nodeType, ownerDocument, defaultChecked, and defaultSelected..and so on should be retrieved and set with the .prop() method. These do not have corresponding attributes and are only properties. .attr() calls .prop() internally so .attr() method will be slightly slower than accessing them directly through .prop().
http://www.cnblogs.com/insus/p/4317185.html
- 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()方法的区别浅析
- jquery中prop()方法和attr()方法的区别浅析
- 关于Bundle及其在不同activity之间的传值
- CSUOJ--1563: Lexicography
- Android的生命周期(三)
- opencv findContours使用问题
- 添加view
- jQuery的prop和attr方法之间区别
- 10000 pcs free gift of chinese top grade brown film faced plywood
- 参数自适应的单层 bp 神经网络
- 019:函数:我的地盘听我的
- mac 下安装android studio
- opencv2的安装、在VS上的配置以及第一个示例
- POJ 1284-Primitive Roots(欧拉函数求原根个数)
- 面试:机器学习--k均值聚类(K-means)
- string char 等字符减去字符0(’0‘)就得到了,该字符的整形