jQuery.data()方法
来源:互联网 发布:网络装修公司哪家最好 编辑:程序博客网 时间:2024/05/22 21:38
data() 方法向被选元素附加数据,或者从被选元素获取数据。也是以一种键值对的形式存在。
实例一:
$("#btn1").click(function(){
$("div").data("greeting", "Hello World"); // 向被选元素附加数据
});
$("#btn2").click(function(){
alert($("div").data("greeting")); // 获取数据,获取键为"greeting"的值,应该为Hello World
});
实例二:
testObj=new Object();
testObj.greetingMorn="Good Morning!";
testObj.greetingEve="Good Evening!";
$("#btn1").click(function(){
$("div").data(testObj);
});
$("#btn2").click(function(){
alert($("div").data("greetingEve")); // 输出"Good Evening!"
});
原帖地址:http://www.w3school.com.cn/jquery/data_jquery_data.asp
- jQuery.data()方法
- jQuery 数据 - data() 方法
- jQuery入门:Data方法
- jQuery.data()方法
- jQuery.data方法
- jQuery-data方法
- jquery - data 方法
- jquery $.data()方法
- jQuery 数据 - jQuery.data() 方法
- jQuery 数据 - jQuery.data() 方法
- jquery data 方法的bug
- HTML5中的data-*属性和jQuery中的.data()方法使用
- HTML5中的data-*属性和jQuery中的.data()方法使用
- HTML5中的data-*属性和jQuery中的.data()方法使用
- jQuery.data( )方法与内存泄漏
- 关于jQuery的data()方法的了解
- 【jQuery】$.data()方法的注意点
- jQuery $.data()方法使用注意细节
- Get(通过远程 HTTP GET 请求载入信息。)
- VC 枚举硬盘 获取硬盘剩余空间
- 工作心得2
- NEHE的OpenGL-Lesson 03 Colors
- 一条进程的栈区、堆区、数据区和代码区在内存中的映射
- jQuery.data()方法
- 让SecureCRT vi中显示多色彩
- Data Types
- Linux串口(serial、uart)驱动程序设计
- 浅谈Android五大布局(一)——LinearLayout、FrameLayout和AbsoulteLayout
- 网络驱动程序编程要点
- 浅谈Android五大布局(二)——RelativeLayout和TableLayout
- NEHE的OpenGL-Lesson 04 Rotations
- ubuntu 11.04 gnome3 下的gedit无法正常显示中文,出现乱码问题解决