jquery遍历函数siblings()用法实例
2015-12-24 00:00
781 查看
本文实例讲述了jquery遍历函数siblings()用法。分享给大家供大家参考,具体如下:
siblings([expr])
得到所有匹配元素集合中各个元素的所有兄弟元素集合。返回匹配元素集合
将得到包含特殊样式‘hilite'元素的所有兄弟元素集合。以下是匹配元素集合
希望本文所述对大家jQuery程序设计有所帮助。
jQuery中siblings()方法用法实例
jquery next nextAll nextUntil siblings的区别介绍
jQuery prev ~ siblings选择器使用介绍
jquery 层次选择器siblings与nextAll的区别介绍
仿jQuery的siblings效果的js代码
siblings([expr])
得到所有匹配元素集合中各个元素的所有兄弟元素集合。返回匹配元素集合
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script src="jquery.js"></script> <script> $(document).ready(function(){ var len = $(".hilite").siblings().css("color", "red").length; $("b").text(len); }); </script> <style> ul { float:left; margin:5px; font-size:16px; font-weight:bold; } p { color:blue; margin:10px 20px; font-size:16px; padding:5px; font-weight:bolder; } .hilite { background:yellow; } </style> </head> <body> <ul> <li>One</li> <li>Two</li> <li class="hilite">Three</li> <li>Four</li> </ul> <ul> <li>Five</li> <li>Six</li> <li>Seven</li> </ul> <ul> <li>Eight</li> <li class="hilite">Nine</li> <li>Ten</li> <li class="hilite">Eleven</li> </ul> <p>Unique siblings: <b></b></p> </body> </html>
$(".hilite").siblings()
将得到包含特殊样式‘hilite'元素的所有兄弟元素集合。以下是匹配元素集合
<li>One</li> <li>Two</li> <li>Four</li> <li>Eight</li> <li class="hilite">Nine</li> <li>Ten</li> <li class="hilite">Eleven</li>
希望本文所述对大家jQuery程序设计有所帮助。
您可能感兴趣的文章:
jQuery中的siblings用法实例分析jQuery中siblings()方法用法实例
jquery next nextAll nextUntil siblings的区别介绍
jQuery prev ~ siblings选择器使用介绍
jquery 层次选择器siblings与nextAll的区别介绍
仿jQuery的siblings效果的js代码
相关文章推荐
- jquery捕捉回车键及获取checkbox值与异步请求的方法
- 基于jQuery实现左右图片轮播(原理通用)
- jQuery实现网页顶部固定导航效果代码
- jQuery基于cookie实现的购物车实例分析
- jquery读写cookie操作实例分析
- jQuery中hover与mouseover和mouseout的区别分析
- javascript与jquery中的this关键字用法实例分析
- jQuery的编写原则
- 使用JQuery结合HIghcharts实现从后台获取JSON实时刷新图表
- jsp jquery 页面中select显示加载后的数据默认选中项
- JQuery 特效
- jQuery小技巧(三)
- jquery的height()和javascript的height总结,js获取屏幕高度
- ASP.NET jquery-1.9.1 语句
- 深入理解jQuery插件开发
- 学习笔记:《jQuery基础教程》第四版第六章课后练习——通过Ajax发送数据
- jQuery获取属性之自己遇到的问题
- jquery中eq和get (
- javascript/jquery判断是否为undefined或是null!
- jQuery获取和设置disabled属性、背景图片路径