jQuery .prop()
.prop()
.prop( propertyName )Returns: Anything
Description: Get the value of a property for the first element in the set of matched elements.
version added: 1.6.prop( propertyName )
- propertyNameType: StringThe name of the property to get.
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()的更多相关文章
- 【jQuery 使用】 利用jQuery.prop("outerHTML")获取包含自身在内的HTML元素的HTML代码
jQuery.html() 是获取当前节点下的html代码,并不包含当前节点本身的代码,然而我们有时候的确需要,可以通过jQuery.prop("outerHTML")的方式设置. ...
- jQuery.prop , jQuery.attr ,jQuery.data
理一下这几个概念吧.根据jquery官网. jquery.prop 获取匹配的元素中第一个元素特定的属性值,或者是设置多个元素的属性值. 有4个重载. .prop(propertyName) 获取属性 ...
- jQuery.prop() 使用详解
prop()函数用于设置或返回当前jQuery对象所匹配的元素的属性值. 该函数属于jQuery对象(实例).如果需要删除DOM元素的属性,请使用removeProp()函数. 语法 jQuery 1 ...
- jquery prop和attr的区别
jquery1.6中新加了一个方法prop(),一直没用过它,官方解释只有一句话:获取在匹配的元素集中的第一个元素的属性值. 大家都知道有的浏览器只要写disabled,checked就可以了,而有的 ...
- jQuery prop() 方法
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- jQuery.prop() 函数详解
prop()函数用于设置或返回当前jQuery对象所匹配的元素的属性值. 该函数属于jQuery对象(实例).如果需要删除DOM元素的属性,请使用removeProp()函数. 语法jQuery 1. ...
- jQuery.prop() 与attr()
1.attr()是jQuery 1.0版本就有的函数,prop()是jQuery 1.6版本新增的函数.毫无疑问,在1.6之前,你只能使用attr()函数:1.6及以后版本,你可以根据实际需要选择对应 ...
- jQuery prop() 与 removeProp()源码解读
prop() prop: function( elem, name, value ) { var ret, hooks, notxml, nType = elem.nodeType; // don't ...
- jQuery prop方法替代attr方法
jquery attr()方法获取标签的 checked 会有问题,所以用了 prop() 方法.
随机推荐
- UITableViewCell背景色.选中背景色,分割线,字体颜色设置
1.系统默认的颜色设置 //无色 cell.selectionStyle = UITableViewCellSelectionStyleNone; //蓝色 cell.selectionStyle = ...
- Delphi 处理异常情况
- Delphi Memo组件
- 3.(基础)tornado的接口调用顺序与模板
上一节介绍了tornado的请求与响应,这一节介绍tornado的接口调用顺序和模板 首先都有哪些接口呢?作用是什么呢?并且都有的时候,执行顺序是怎么样的呢? 接口 1.initialize,表示初始 ...
- C与汇编混合编程
C中调用汇编,要把汇编定义为全局的,加.global C内嵌汇编 __asm__( :汇编语句部分 :输出部分 :输入部分 :破坏描述部分 ); 用C内嵌汇编的方式:实现LED的点亮 //#defin ...
- 阿里云(ecs服务器)使用3-安装mysql数据库以及远程部署
1.安装 1.下载rpm包,下载地址 http://dev.mysql.com/downloads/mysql/,选择Linux-Generic版本 .新建 /usr/local/mysql 文件夹, ...
- 标准C语言(5)
无法预知的数字叫随机数,rand标准函数可以用来获得随机数,为了使用这个标准函数需要包含stdlib.h头文件 srand标准函数用来设置随机数种子,这个函数把一个整数作为种子使用不同的种子可以得到不 ...
- JS 深拷贝/合并
var mix = function(r, s, ov) { if (!s || !r) return r; if (ov === undefined) ov = true; for (var p i ...
- tcpdump工具抓到的cap文件
一.链路层 ---> 以太网数据包 一个数据包被称为一帧, 制定这个规则的协议就是以太网协议.一个完整的以太网数据包如下图所示: 整个数据帧由首部.数据和尾部三部分组成,首部固定为14个字节 ...
- python 异常处理(五)
异常处理&异常基类 1.处理异常 try.....except 语法: 1) try: 放可能会出现问题的代码 except: 处理错误的方式 例如: try: print(ab) #无错执 ...