欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時(shí)間:2015年01月07日 10:48:05   投稿:shichen2014  
這篇文章主要介紹了jQuery中next()方法用法,實(shí)例分析了next()方法的功能、定義及獲得匹配元素集合中每個(gè)元素緊鄰的同輩元素使用技巧,需要的朋友可以參考下

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

此方法獲得匹配元素集合中每個(gè)元素緊鄰的同輩元素。
也可以使用可選的表達(dá)式對(duì)同輩元素集合進(jìn)行篩選。

語法結(jié)構(gòu):

復(fù)制代碼 代碼如下:
$(selector).next(expr)

參數(shù)列表:

參數(shù) 描述
expr 可選。用于篩選的表達(dá)式

實(shí)例代碼:

實(shí)例一:

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

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8"/>
<meta name="author" content="http://www.dbjr.com.cn/" />
<title>next()函數(shù)-腳本之家</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(){
  $("p").next().css("color","blue")
})
</script>
</head>
<body>
<div class="father">
  <p>我是p元素</p>
  <span>我是span元素</span>
  <p>我是p元素</p>
  <div>我是div元素</div>
</div>
</body>
</html>

將每一個(gè)p元素緊鄰的元素中的字體顏色設(shè)置為藍(lán)色。

實(shí)例二:

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

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8"/>
<meta name="author" content="http://www.dbjr.com.cn/" />
<title>next()函數(shù)-腳本之家</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(){
  $("p").next("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>

將與p元素緊鄰的span元素中的字體顏色設(shè)置為藍(lán)色。

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

相關(guān)文章

最新評(píng)論