jQuery 选择器
来源:互联网 发布:淘客如何找商家数据 编辑:程序博客网 时间:2024/06/16 16:00
attribute_filter_selector.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>属性过滤选择器</title><script type="text/javascript" src="../jquery-1.11.2.js"></script><script type="text/javascript">$(document).ready(function(e) {$("div[id]").css("background","#0F0"); //具有id属性的元素的背景色$('div[id="hey"]').css("font-size","14px"); //id属性为hey元素的字体$('div[id!="hey"]').css("font-size","16px"); //id属性不为hey元素的字体$('div[id^="the"]').css("color","#090"); //id属性以the开头的的前景色$('div[id$="be"]').css("color","#C00"); //id属性以be结束的前景色$('div[id*="er"]').css("color","#360"); //id属性值中包含er的前景色 });</script></head><body> <div id="hey">具有id属性hey的元素</div> <div id="there">具有id属性there的元素</div> <div id="adobe">具有id属性adobe的元素</div> <div>无id属性</div> </body></html>
simple_filter_selector.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>简单过滤选择器</title><style type="text/css"> table{ border-collapse:collapse; } table, td, th{ border:1px solid black; } th{ width:100px; }</style><script type="text/javascript" src="../jquery-1.11.2.js"></script><script type="text/javascript"> $(document).ready(function(e) { $("tr:first").css("background","#FF0"); //表格第一行显示黄色 $("tr:last").css("background","#FCF"); //表格的最后一行显示暖红//$("tr:odd ").css("background","#BBBBFF"); //表格的奇数行显示蓝色 //$('tr:even ').css('background', '#DADADA'); //表格的偶数行显示灰色 $("tr:even:not(:first)").css("background","#BBBBFF"); //偶数行,但滤除第一行。 $("tr:odd:not(:last)").css("background","#DADADA"); // 奇数行,但滤除最后一行。 //$("tr:eq(4)").css("background","#F00"); //让第4行的背景为红色 //$("tr:gt(4)").css("background","#000"); //大于第4行的显示黑色 //$("tr:lt(2)").css("background","#FFC"); //小于第2行显示黄色 });</script></head><body><table width="600" border="1"> <tr> <th scope="row">表格行1</th> <td> </td> </tr> <tr> <th scope="row">表格行2</th> <td> </td> </tr> <tr> <th scope="row">表格行3</th> <td> </td> </tr> <tr> <th scope="row">表格行4</th> <td> </td> </tr> <tr> <th scope="row">表格行5</th> <td> </td> </tr> <tr> <th scope="row">表格行6</th> <td> </td> </tr></table></body></html>
content_filter_selector.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>内容过滤选择器示例</title><style type="text/css"> table{ border-collapse:collapse; }table, td, th{ border:1px solid black; } body,td,th {font-size: 9pt;}</style><script type="text/javascript" src="../jquery-1.11.2.js"></script><script type="text/javascript"> $(document).ready(function(e) { $("td:contains('张')").css("background","#FFC"); //将文字中含张的背景设置为淡黄 $("td:empty").css("background","#060"); //单元格中不包含内容的颜色,也不包含 空格的空单元格 $("td:has(p)").css("background","#9F0"); //单元格中包含子元素<p>的颜色 $("td:parent").css("color","#060"); //单元格中包含文本的前景色 });</script></head><body><table width="600" border="1"> <tr> <td>张三丰</td> <td>何足道</td> <td>觉远大师</td> </tr> <tr> <td>常敬之</td> <td>张翠山</td> <td>天鹰教</td> </tr> <tr> <td>张五侠</td> <td> </td> <td>金毛狮王</td> </tr> <tr> <td>张大千</td> <td> </td> <td> </td> </tr> <tr> <td>丁乐然</td> <td><p>丁春秋</p> <p>有名的江湖民间高手</p></td> <td><p>丁不四</p> <p>江湖闲散人员,喜欢胡乱杀人,遇即避之。</p></td> </tr> <tr> <td>张秋山</td> <td>李秋水</td> <td>颜不四</td> </tr></table></body></html>
hidden_filter_selector.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>可见性过滤选择器</title><style> /*定义div的外观*/div {width: 70px;height: 40px;background: #ee77ff;margin: 5px;float: left;} span {display: block;clear: left;color: #060;} /*让页面元素具有隐藏的效果*/ .starthidden {display: none;} body,td,th {font-size: 9pt;}</style> <script type="text/javascript" src="../jquery-1.11.2.js"></script><script type="text/javascript">$(document).ready(function(e) {//在一些浏览器中,隐藏元素也包含 <head>、<title>、<script>等元素//获取隐藏元素但排除<script>var hiddenEls = $("body").find(":hidden").not("script"); $("span:first").text("找到" + hiddenEls.length + "个隐藏元素"); //$("div:hidden").show(3000); //动画的显示隐藏元素$("span:last").text("找到" + $("input:hidden").length + "个表单隐藏域"); //为可见的按钮元素关联事件处理代码$("div:visible").click(function () { $(this).css("background", "yellow"); }); //为按钮关联事件处理代码,显示隐藏页面元素$("button").click(function () { $("div:hidden").show("fast"); }); });</script></head> <body> <span></span> <div></div> <div style="display:none;">隐藏的元素</div> <div></div> <div class="starthidden">隐藏的页面元素</div> <div></div> <form> <input type="hidden" /> <input type="hidden" /> <input type="hidden" /> </form> <span> </span> <button>显示隐藏元素</button> </body></html>
$("#div1 > p") 查找div1的元素中的子标签为p的元素 只查找一代
$("#div1 p") 查找div1的元素中的子标签为p的所有元素(包括孙代... 0 0
- CSS选择器,jQuery选择器
- jQuery选择器 CSS选择器
- JQuery选择器(选择器简介)
- jQuery选择器 基本选择器
- jQuery选择器 层次选择器
- jQuery选择器 表单选择器
- Jquery选择器-基本选择器
- jQuery选择器之类选择器
- jQuery选择器之类选择器
- jQuery选择器之类选择器
- Jquery选择器--过滤选择器
- JQuery选择器
- jquery 选择器
- Jquery选择器
- jQuery选择器
- jQuery 选择器
- JQuery选择器
- JQuery选择器
- xib文件中设置UIView的约束,设置完了为什么没效果?
- Java EE开发系列教程
- magento1.x执行流程
- tar命令
- 如何用excel創建金字塔
- jQuery 选择器
- win+R:dxdiag;显卡:VGA标准配置器;驱动程序模型:未知
- 结构型模式之适配器ADAPTER
- Linux上test环境部署流程及命令
- STM32F103程序设计-8-USB转TTL串口(printf)
- webpack loader加载器
- Java小记__抽象类和接口
- LeetCode : Same Tree
- docker 镜像centos 6.x 中文支持解决