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

jQuery+css last-child實(shí)現(xiàn)選擇最后一個子元素操作示例

 更新時間:2018年12月10日 10:21:01   作者:北方的刀郎  
這篇文章主要介紹了jQuery+css last-child實(shí)現(xiàn)選擇最后一個子元素操作,結(jié)合實(shí)例形式分析了jQuery結(jié)合css進(jìn)行頁面元素選擇與樣式修改相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了jQuery+css last-child實(shí)現(xiàn)選擇最后一個子元素操作。分享給大家供大家參考,具體如下:

<!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" />
<title>www.dbjr.com.cn jQuery選擇器</title>
<style>
.red{color:#FF0000;}
</style>
</head>
<body>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
//$('div p:last').addClass("red"); //$('div p:last') 選擇 最后一個P元素 并高亮顯示得出結(jié)果如下:
$('div p:last-child').addClass("red");//$('div p:last-child') 將選擇所有位于div最后一個p子元素,并高亮:
});
</script>
<div>
<p>Paragraph</p>
<p>Paragraph</p>
<p>Paragraph</p>
</div>
<div>
<p>Paragraph</p>
<p>Paragraph</p>
<p>Paragraph</p>
</div>
<div>
<p>Paragraph</p>
<p>Paragraph</p>
<p>Paragraph<span>sssssssssss</span></p>
</div>
</body>
</html>

這里使用在線HTML/CSS/JavaScript代碼運(yùn)行工具http://tools.jb51.net/code/HtmlJsRun測試,可得到如下運(yùn)行效果:

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery頁面元素操作技巧匯總》、《jQuery常見事件用法與技巧總結(jié)》、《jQuery常用插件及用法總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》及《jquery選擇器用法總結(jié)

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

相關(guān)文章

最新評論