JQuery 学习笔记 选择器之五
作者:bea
代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" con
代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="js/jquery-1.3.2.js"></script>
<script type="text/javascript"><!--
$(function(){
$("#aFirst").click(function(){
$("div[id]").each(function(){
$(this).css("background","#773300");
})
})
$("#aSecond").click(function(){
$("div[id = div2]").each(function(){
$(this).css("background","#8833ff");
})
})
$("#aThird").click(function(){
$("div[id != div2]").each(function(){
$(this).css("background","#87f289");
})
})
$("#aFourthly").click(function(){
$("div[name ^= DIV]").each(function(){
$(this).css("background","#140586");
})
})
$("#aFifthly").click(function(){
$("div[name $= ly]").each(function(){
$(this).css("background","#930584");
})
})
$("#aSixth").click(function(){
$("div[name *= th]").each(function(){
$(this).css("background","#099483");
})
})
$("#aSeventh").click(function(){
$("div[id][name !=Fifthly][name *= i]").each(function(){
$(this).css("background","#938607");
})
})
})
// --></script>
<title>无标题文档</title>
</head>
<body>
<a href="#" onclick="javascript:location.reload();">重置</a>
<div id="div1" name ="DIV_First">div1</div>
<div id="div2" name ="DIV_Second">div2</div>
<div id="div3" name = "DIV_Third">div3</div>
<div id="div4" name = "DIV_Fourthly">div4</div>
<div id="div5" name="Fifthly">div5</div>
<a href="#" id="aFirst">设置页面所有DIV元素的背景颜色</a>|
<a href="#" id="aSecond">设置第2个DIV的背景颜色</a>|
<a href="#" id="aThird">设置除第2个DIV以外DIV的背景颜色</a>|
<a href="#" id="aFourthly">设置name属性值以DIV开头的元素</a>|
<a href="#" id="aFifthly">设置name属性值以ly结尾的元素</a>|
<a href="#" id="aSixth">设置name属性值包含th的元素</a>|
<a href="#" id="aSeventh">综合应用</a>
</body>
</html>
1.$("selector [Attribute]")--注,以下直接简写为[Attribute]
描述:获取selector选择的元素集合里,拥有Attribute属性的元素集合。应该较为简单,在这就不做啥详细说明了,有不了解的跟下贴,哈
返回值:Array(Element);
2.[attribute=value]
描述:获取selector选择的元素集合里,拥有Attribute属性值等于Value的元素集合。
返回值:Array(Element);
3.[attribute!=value]
描述:获取selector选择的元素集合里,拥有Attribute属性值不等于Value的元素集合。
返回值:Array(Element);
4.[attribute^=value]
描述:获取selector选择的元素集合里,拥有Attribute属性值以Value开头的元素集合。相当于正则的规范^^
返回值:Array(Element);
5.[attribute$=value]
描述:获取selector选择的元素集合里,拥有Attribute属性值以Value结尾的元素集合。相当于正则的规范^^
返回值:Array(Element);
6.[attribute*=value]
描述:获取selector选择的元素集合里,拥有Attribute属性值包含Value的元素集合。
返回值:Array(Element);
7.[selector1][selector2][selectorN]
描述:与第一章中,基本选择器综合应用一样,此方法也就是前6种的综合版,就如我例子中$("div[id][name !=Fifthly][name *= i]")就是取所有的div元素中,拥有ID属性&&name属性!=Fifthly&&name属性包含字符i的DIV元素的集合,大家用我例子试下就能很清楚的了解看到效果了,哈。好好利用此方法应该很有用^^
返回值:Array(Element);
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- js 字符串操作函数
- javaScript Array(数组)相关方法简述
- 对象特征检测法判断浏览器对javascript对象的支持
- javascript 一个函数对同一元素的多个事件响应
- IE中radio 或checkbox的checked属性初始状态下不能选中显示问题
- javascript 解析后的xml对象的读取方法细解
- jquery 将disabled的元素置为enabled的三种方法
- javaScript 判断字符串是否为数字的简单方法
- 利用javascript/jquery对上传文件格式过滤的方法
- javascript 动态table添加colspan owspan 参数的方法
- jquery 表单下所有元素的隐藏
- 运用jquery实现table单双行不同显示并能单行选中
- 用JQuery 实现AJAX加载XML并解析的脚本
- Prototype Selector对象学习
- Prototype 工具函数 学习
- 用js模仿word格式刷功能实现代码 [推荐]
- JQuery CSS样式控制 学习笔记
- JQuery 学习笔记 element属性控制
- JQuery 学习笔记 选择器之六