第二篇:jQuery选择器(jQuery)

jQuery选择器02

选择器实例选取
:first$("p:first")第一个<p>元素
:last$("p:last")最后一个元素
:even$("tr:even")所有偶数<tr>元素
:odd$("tr:odd")所有奇数<tr>元素

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8"/>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.min.js"></script>
<script type="text/javascript"> 
	$(document).ready(function(){
    $("p:first").css("background-color","#B2E0FF");
}); 
</script>	
</head>
<body>
<h1>欢迎来到音乐网站!</h1>
<p class="intro">My name is YanHSama!</p>
<p>Can you tell me ?</p>
<p>I like music very much!</p>
<div id="choose">
Which is your favourite:
<ul>
<li>music</li>
<li>book</li>
<li>sport</li>
</ul>
</div>
</div>
</body>
</html>

 

 


 

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8"/>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.min.js"></script>
<script type="text/javascript"> 
	$(document).ready(function(){
    $("p:last").css("background-color","#B2E0FF");
}); 
</script>	
</head>
<body>
<h1>欢迎来到音乐网站!</h1>
<p class="intro">My name is YanHSama!</p>
<p>Can you tell me ?</p>
<p>I like music very much!</p>
<div id="choose">
Which is your favourite:
<ul>
<li>music</li>
<li>book</li>
<li>sport</li>
</ul>
</div>
</div>
</body>
</html>

 

 


 

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8"/>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.min.js"></script>
<script type="text/javascript"> 
	$(document).ready(function(){
    $("tr:even").css("background-color","#B2E0FF");
}); 
</script>	
</head>
<body>
<p>欢迎来到音乐网站!</p>
<p class="intro">My name is YanHSama!</p>
<p>Can you tell me ?</p>
<p>I like music very much!</p>
<div id="choose">
Which is your favourite:
<ul>
<li>music</li>
<li>book</li>
<li>sport</li>
<li>climb</li>
</ul>
</div>
<div id="info">
	<table border="1">
		<tr>
			<th>1</th>
			<th>2</th>
			<th>3</th>
			<th>4</th>
			<th>5</th>
			<th>6</th>
		</tr>
		<tr>
			<td>d</td>
			<td>的</td>
			<td>发</td>
			<td>g</td>
			<td>y</td>
			<td>g</td>
		</tr>
		<tr>
			<td>d</td>
			<td>的</td>
			<td>发</td>
			<td>g</td>
			<td>y</td>
			<td>g</td>
		</tr>
		<tr>
			<td>d</td>
			<td>的</td>
			<td>发</td>
			<td>g</td>
			<td>y</td>
			<td>g</td>
		</tr>
		<tr>
			<td>d</td>
			<td>的</td>
			<td>发</td>
			<td>g</td>
			<td>y</td>
			<td>g</td>
		</tr>
		<tr>
			<td>d</td>
			<td>的</td>
			<td>发</td>
			<td>g</td>
			<td>y</td>
			<td>g</td>
		</tr>
		<tr>
			<td>d</td>
			<td>的</td>
			<td>发</td>
			<td>g</td>
			<td>y</td>
			<td>g</td>
		</tr>
	</table>
</div>
</body>
</html>

 


 

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8"/>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.min.js"></script>
<script type="text/javascript"> 
	$(document).ready(function(){
    $("tr:odd").css("background-color","#B2E0FF");
}); 
</script>	
</head>
<body>
<p>欢迎来到音乐网站!</p>
<p class="intro">My name is YanHSama!</p>
<p>Can you tell me ?</p>
<p>I like music very much!</p>
<div id="choose">
Which is your favourite:
<ul>
<li>music</li>
<li>book</li>
<li>sport</li>
<li>climb</li>
</ul>
</div>
<div id="info">
	<table border="1">
		<tr>
			<th>1</th>
			<th>2</th>
			<th>3</th>
			<th>4</th>
			<th>5</th>
			<th>6</th>
		</tr>
		<tr>
			<td>d</td>
			<td>的</td>
			<td>发</td>
			<td>g</td>
			<td>y</td>
			<td>g</td>
		</tr>
		<tr>
			<td>d</td>
			<td>的</td>
			<td>发</td>
			<td>g</td>
			<td>y</td>
			<td>g</td>
		</tr>
		<tr>
			<td>d</td>
			<td>的</td>
			<td>发</td>
			<td>g</td>
			<td>y</td>
			<td>g</td>
		</tr>
		<tr>
			<td>d</td>
			<td>的</td>
			<td>发</td>
			<td>g</td>
			<td>y</td>
			<td>g</td>
		</tr>
		<tr>
			<td>d</td>
			<td>的</td>
			<td>发</td>
			<td>g</td>
			<td>y</td>
			<td>g</td>
		</tr>
		<tr>
			<td>d</td>
			<td>的</td>
			<td>发</td>
			<td>g</td>
			<td>y</td>
			<td>g</td>
		</tr>
	</table>
</div>
</body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值