久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      jquery怎么查詢最后一個子元素

      兩種方法:1、利用children()和“:last-child”選擇器,語法“$(父元素).children(":last-child")”。2、用children()和eq(),語法“$(父元素).children().eq(-1)”。

      jquery怎么查詢最后一個子元素

      本教程操作環(huán)境:windows7系統(tǒng)、jquery1.10.2版本、Dell G3電腦。

      jquery查詢最后一個子元素的兩種方法

      方法1:使用children():last-child選擇器

      • 使用children()獲取指定父節(jié)點下的全部直接子元素

      • 利用:last-child選取子元素集合中最后一個元素,即最后一個子元素

      示例:

      <!DOCTYPE html> <html>  	<head> 		<meta charset="UTF-8"> 		<script src="js/jquery-1.10.2.min.js"></script> 		<script> 			$(function () {             $("button").click(function () { 				$("ul").children(":last-child").css("color","red");             })         })     </script> 	</head> 	<body> 		<ul> 			<li>香蕉</li> 			<li>蘋果</li> 			<li>梨子</li> 			<li>橘子</li> 		</ul> 		<button>父元素ul的最后一個子元素</button> 	</body> </html>

      jquery怎么查詢最后一個子元素

      方法2:使用children()和eq()

      • 使用children()獲取指定父節(jié)點下的全部直接子元素

      • 利用eq(-1)選取子元素集合中最后一個元素,即最后一個子元素

      在上例的基礎上,修改:

      $(function() { 	$("button").click(function() { 		$("ul").children().eq(-1).css("color", "red"); 	}) })

      jquery怎么查詢最后一個子元素

      【推薦學習:jQuery視頻教程、web前端視頻】

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號