JQuery 属性操作方法
来源:互联网 发布:windows 10和windows7 编辑:程序博客网 时间:2024/05/21 00:01
以下的方法可以用于获得或者设元素的DOM属性
addClass()
Sample:
1. $("p:first").addClass("class1");//如需加多个,用空格分隔
2. $("p").addClass(function(n){return "class"+n;});
注:n为选取器的index.
hasClass()
Sample
$("p:first").hasClass("class1");
removeClass()
Sample
$("p").removeClass("class1");
toggleClass()
Sample:
1. $("p").toggleClass("class1");
2. $(selector).toggleClass(class, switch);
3. $(selector).toggleClass(function,switch);
$('ul li').toggleClass(function(){
return 'listitem_' + $(this).index();
});
attr()
Sample:
1. $("img").attr("width", "150");
2. $("img").attr("width");
3. $(selector).attr(attribute, function(index,oldvalue));
$("img").attr("width",function(n,v)
{ return v-10;});
4. $("img").attr({width:"50",height:"34"});
html()
Sample
1. $("p").html();
2. $("p").html("Hello World");
removeAttr()
Sample
$("p").removeAttr("id");
val()
Sample
1. $(":text").val("Hello World");
2. $(":text").val();
3. $("input:checkbox").val(function(){
return "check_" + $(this).val();
});
- JQuery属性操作方法
- JQuery 属性操作方法
- jQuery 属性操作方法
- jQuery 属性操作方法
- JQuery属性操作方法
- jQuery 属性操作方法
- jQuery 属性操作方法
- jQuery 属性操作方法
- JQuery文档操作方法跟JQuery属性操作方法跟JQuery CSS操作函数
- jQuery基础系列(二):jQuery属性操作方法
- 有关jquery与DOM节点操作方法和属性记录
- jQuery 文档操作方法
- jQuery 文档操作方法
- Jquery Select操作方法集合
- Jquery Select操作方法
- Jquery Select操作方法集合
- jQuery 文档操作方法
- jQuery队列操作方法实例
- linux内核学习(9)启动全过程概述之内核映像结构
- ubuntu 10.10 源码编译安装mysql 5.5
- [转]从MySpace基于.NET平台的六次重构经历感受分布式
- TrueCrypt 7.0a的安装
- abap assigning a structure by component
- JQuery 属性操作方法
- 选摘
- Delphi GDI+ 实现简单画图
- abap casting with field symbol type
- linux 8250驱动笔记
- URI、URL、URN
- 人生三件事/三句话/三乐/三不
- DOS命令行删除N天以前的文件
- 索引