博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jQuery 常用getter&setter
阅读量:4317 次
发布时间:2019-06-06

本文共 2406 字,大约阅读时间需要 8 分钟。

&

asGet:Get the value of a property/an attribute for the first element in the set of matched elements.

asSet:Set one or more  properties/attributes for the set of matched elements.

Note:To retrieve and change DOM properties such as the checkedselected, or disabled state of form elements, use the  method

e.g:

//suppose ele is a checkboxif(ele.checked)if(ele.prop('checked'))if(ele.is(':checked'))

asGet:Get the computed style properties for the first element in the set of matched elements.

asSet:Set one or more CSS properties for the set of matched elements.

: Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the state argument.

asGet:Get the current value of the first element in the set of matched elements.

asSet:Set the value of each element in the set of matched elements.

.

asGet:Get the combined text contents of each element in the set of matched elements, including their descendants.

asSet:Set the content of each element in the set of matched elements to the specified text.

asGet:Get the HTML contents of the first element in the set of matched elements.

asSet:Set the HTML contents of each element in the set of matched elements.

asGet:Get the current coordinates of the first element in the set of matched elements, relative to the document.

asSet:Set the current coordinates of every element in the set of matched elements, relative to the document.

Note:The .offset() method allows us to retrieve the current position of an element (specifically its border box, which excludes margins) relative to the document.Contrast this with , which retrieves the current position relative to the offset parent.

position()返回相对于父元素的偏移量

width()height()获得元素的宽高,不包括内外边距及边框,设置时会受到盒模型的影响

innerWidth()innerHeight()包含内边距

outerWidth()outerHieght()包含内边距及边框

scrollTop()scrollLeft()获得或设置元素滚动条的位置

asGet: Set Return the value at the named data store for the first element in the jQuery collection, as set by data(name, value) or by an HTML5 data-* attribute.

asSet: Store arbitrary(任意的) data associated with the matched elements.

Note:Using the object directly to get or set values is faster than making individual calls to .data() to get or set each value:

var mydata = $( "#mydiv" ).data();if ( mydata.count < 9 ) {  mydata.count = 43;  mydata.status = "embiggened";}

 

转载于:https://www.cnblogs.com/goOtter/p/9533582.html

你可能感兴趣的文章
LINQ to SQL vs. NHibernate
查看>>
基于Angular5和WebAPI的增删改查(一)
查看>>
windows 10 & Office 2016 安装
查看>>
最短路径(SP)问题相关算法与模板
查看>>
js算法之最常用的排序
查看>>
Python——交互式图形编程
查看>>
经典排序——希尔排序
查看>>
团队编程项目作业2-团队编程项目代码设计规范
查看>>
英特尔公司将停止910GL、915GL和915PL芯片组的生产
查看>>
团队编程项目作业2-团队编程项目开发环境搭建过程
查看>>
Stax解析XML示例代码
查看>>
cookie
查看>>
二级图片导航菜单
查看>>
<Using parquet with impala>
查看>>
07-Java 中的IO操作
查看>>
uclibc,eglibc,glibc之间的区别和联系【转】
查看>>
Java魔法堂:找外援的利器——Runtime.exec详解
查看>>
mysql数据库存放路径
查看>>
TestNG(五)常用元素的操作
查看>>
解决 Visual Studio 点击添加引用无反应的问题
查看>>