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() 方法.
随机推荐
- js 控制加载|移除 script 与 link 文件
js 加载 script 文件 /** * 加载 script 文件 * @param src */ function loadScript(src) { var addSign = true; va ...
- 1.什么是bat文件
bat文件是dos下的批处理文件.批处理文件是无格式的文本文件,它包含一条或多条命令.它的文件扩展名为 .bat 或 .cmd. 在命令提示下输入批处理文件的名称,或者双击该批处理文件,系统就会调用c ...
- Apache(web服务器)与Tomcat(应用服务器)搭建集群
web服务器:Apache.Nginx.IIS等 应用服务器:Tomcat.JBoss.Weblogic等 现在web服务器和应用服务器其实界限已经不是太清晰了,大部分的应用服务器也包含一些web服务 ...
- 18、nginx优化
一.性能优化概述 基询imm能优化,那么在性能优化这一章,我们将分为如下几个方面做介绍 1.首先我们需要了解性能优化要考虑哪些方面. 2.然后我们需要了解性能优化必须要用到的压力测试工具ab. 3.最 ...
- python将str类型的数据变成datetime时间类型数据
如下: import datetime date_str = '2019_05_09' date_date = datetime.date(*map(int, date_str.split('_')) ...
- 利用SAX解析读取XML文件
xml 这是我的第一个BLOG,今天在看<J2EE应用开发详解>一书,书中讲到XML编程,于是就按照书中的步骤自己测试了起来,可是怎么测试都不成功,后来自己查看了一遍源码,发现在读 ...
- pthread_cond_wait
while(1) 33 { 34 mm* p = NULL; 35 pthread_mutex_lock(&mutex); 36 while(head == NULL) 37 pthread_ ...
- 清北学堂dp图论营游记day2
上午讲数位dp和背包问题. 先讲背包: 完全背包:换了个顺序: 多重背包: 多重背包优化: 这样把每个物品分成这些组,那么把他们转变成不同的物品,就变成了01背包问题: 滑动窗口取最值问题.单调队列优 ...
- Mongodb中的js语法
定义一个变量 > var len = 10; For循环 这里的db和data都可以作为对象 save是方法 接收一个临时定义的对象 > for(var i = 0; i < len ...
- 免费自动化测试工具Katalon Studio入门
Katalon Studio 一.简介: Katalon Studio 是一个在网页应用.移动和网页服务方面功能强大的自动化测试解决方案.基于 Selenium 和 Appium 框架,Katalon ...