jQuery中prevAll()方法用法实例
更新时间:2015年01月08日 09:35:20 投稿:shichen2014
这篇文章主要介绍了jQuery中prevAll()方法用法,实例分析了prevAll()方法的功能、定义及查找匹配元素集合之前所有同辈元素的使用技巧,需要的朋友可以参考下
本文实例讲述了jQuery中prevAll()方法用法。分享给大家供大家参考。具体分析如下:
此方法查找匹配元素集合之前所有的同辈元素。
同辈元素集合可以通过选择器进行筛选。
语法结构:
复制代码 代码如下:
$("selector").prevAll(expr)
参数列表:
实例代码:
实例一:
复制代码 代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="https://www.jb51.net/" />
<title>脚本之家</title>
<style type="text/css">
.father{
height:200px;
width:200px;
border:1px solid blue;
}
</style>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".father div").prevAll().css("color","blue")
})
</script>
</head>
<body>
<div class="father">
<p>我是p元素</p>
<span>我是span元素</span>
<p>我是p元素</p>
<div>我是div元素</div>
</div>
</body>
</html>
实例二:
复制代码 代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset=" utf-8">
<meta name="author" content="https://www.jb51.net/" />
<title>脚本之家</title>
<style type="text/css">
.father{
height:200px;
width:200px;
border:1px solid blue;
}
</style>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".father div").prevAll("span").css("color","blue")
})
</script>
</head>
<body>
<div class="father">
<p>我是p元素</p>
<span>我是span元素</span>
<p>我是p元素</p>
<div>我是div元素</div>
</div>
</body>
</html>
希望本文所述对大家的jQuery程序设计有所帮助。
相关文章
基于jquery实现可定制的web在线富文本编辑器附源码下载
UEditor的功能非常强大,官方已配备了php,asp,asp.net,java等语言的上传程序,拿来就可以使用,当然ueditor更具有功能插件接口,很轻松地添加自己定义功能到编辑器中,方便项目的不同需求2015-11-11
jQuery插件FusionWidgets实现的Cylinder图效果示例【附demo源码】
这篇文章主要介绍了jQuery插件FusionWidgets实现的Cylinder图效果,结合实例形式分析了jQuery使用FusionWidgets结合swf文件读取xml数据并采用Cylinder图展示的相关实现技巧,并附带demo源码供读者下载参考,需要的朋友可以参考下2017-03-03


最新评论