亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

jQuery中prevUntil()方法用法實(shí)例

 更新時(shí)間:2015年01月08日 09:51:03   投稿:shichen2014  
這篇文章主要介紹了jQuery中prevUntil()方法用法,實(shí)例分析了按條件查找匹配元素之前所有的同輩元素的使用技巧,需要的朋友可以參考下

本文實(shí)例講述了jQuery中prevUntil()方法用法。分享給大家供大家參考。具體分析如下:

此函數(shù)查找匹配元素之前所有的同輩元素,直到遇到expr表達(dá)式、DOM元素或者jQuery元素匹配的那個(gè)元素為止。
可以使用可選的表達(dá)式對同輩元素集合進(jìn)行篩選。

注意:祖先元素中并不包含expr表達(dá)式、DOM元素或者jQuery元素匹配的元素。

語法:

語法 一:

復(fù)制代碼 代碼如下:
$(selector).prevUntil(expr,filter)

參數(shù)列表:
參數(shù) 描述
expr 可選。用于篩選祖先元素的表達(dá)式。
filter 可選。用于對取得的祖先元素集合進(jìn)行篩選。

實(shí)例:

實(shí)例一:

復(fù)制代碼 代碼如下:

<!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" />
<meta name="author" content="http://chabaoo.cn/" />
<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").prevUntil(".firstp").css("color","blue")
    })
</script>
</head>
<body>
<div class="father">
  <p class="firstp">我是p元素</p>
  <span>我是span元素</span>
  <p>我是p元素</p>
  <div>我是div元素</div>
</div>
</body>
</html>

實(shí)例二:

復(fù)制代碼 代碼如下:

<!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" />
<meta name="author" content="http://chabaoo.cn/" />
<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").prevUntil(".firstp","span").css("color","blue")
    })
</script>
</head>
<body>
<div class="father">
  <p class="firstp">我是p元素</p>
  <span>我是span元素</span>
  <p>我是p元素</p>
  <div>我是div元素</div>
</div>
</body>
</html>

語法二:

復(fù)制代碼 代碼如下:
$(selector).prevUntil(element,filter)

參數(shù)列表:
參數(shù) 描述
element 可選。用于篩選祖先元素的DOM元素或者jQuery元素
filter 可選。用于對取得的祖先元素集合進(jìn)行篩選。

實(shí)例:

實(shí)例一:

復(fù)制代碼 代碼如下:

<!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" />
<meta name="author" content="http://chabaoo.cn/" />
<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").prevUntil(document.getElementById("firstp")).css("color","blue")
    })
</script>
</head>
<body>
<div class="father">
  <p id="firstp">我是p元素</p>
  <span>我是span元素</span>
  <p>我是p元素</p>
  <div>我是div元素</div>
</div>
</body>
</html>

實(shí)例二:

復(fù)制代碼 代碼如下:

<!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" />
<meta name="author" content="http://chabaoo.cn/" />
<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").prevUntil(document.getElementById("firstp"),"span").css("color","blue")
    })
</script>
</head>
<body>
<div class="father">
  <p id="firstp">我是p元素</p>
  <span>我是span元素</span>
  <p>我是p元素</p>
  <div>我是div元素</div>
</div>
</body>
</html>

希望本文所述對大家的jQuery程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論