码迷,mamicode.com
首页 > Web开发 > 详细

jQuery Attributes vs. Properties

时间:2015-07-21 20:19:52      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:

Attributes vs. Properties

attributesproperties之间的差异在特定情况下是很重要。jQuery 1.6之前 ,.attr()方法在取某些 attribute 的值时,会返回 property 的值,这就导致了结果的不一致。从 jQuery 1.6 开始, .prop()方法 方法返回 property 的值,而 .attr() 方法返回 attributes 的值。

例如, selectedIndextagNamenodeNamenodeTypeownerDocumentdefaultChecked, 和 defaultSelected 应使用.prop()方法进行取值或赋值。 在jQuery1.6之前,这些属性使用.attr()方法取得,但是这并不是元素的attr属性。他们没有相应的属性(attributes),只有特性(property)。

jQuery Attributes vs. Properties

标签:

原文地址:http://www.cnblogs.com/darr/p/4665311.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!