首页 > Web开发 > 详细

jQuery .prop()

时间:2019-07-10 15:19:38      阅读:109      评论:0      收藏:0      [点我收藏+]

.prop()

.prop( propertyName )Returns: Anything

Description: Get the value of a property for the first element in the set of matched elements.

The .prop() method gets the property value for only the first element in the matched set. It returns undefined for the value of a property that has not been set, or if the matched set has no elements. To get the value for each element individually, use a looping construct such as jQuery‘s .each() or .map() method.

Note: Attempting to change the type property (or attribute) of an input element created via HTML or already in an HTML document will result in an error being thrown by Internet Explorer 6, 7, or 8.

 

Attributes vs. Properties

The difference between attributes and properties can be important in specific situations.

Before jQuery 1.6, the .attr() method sometimes took property values into account when retrieving some attributes, which could cause inconsistent behavior.

As of jQuery 1.6, the .prop() method provides a way to explicitly retrieve property values, while .attr() retrieves attributes.

 

 

 

 

 

jQuery .prop()

原文:https://www.cnblogs.com/chucklu/p/11164056.html

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