[jQuery] Hover(over, out) 事件
說明:
- 類似Javascript中的onMouseOver, onMouseOut
- 可一次設定某(些)物件的Over,Out動作
範例:
<HEAD>
<script type="Text/JavaScript" src="js/jQuery.js"></script>
<script type="Text/JavaScript">
$(document).ready(function(){
	$('div').hover(
			function()
			{
				$(this).addClass('iOver');
			},
			function()
			{
				$(this).removeClass('iOver');
				//$(this).addClass('iOut');
			}
		);
	$('#myBd tr').hover(
		function(){
			$(this).addClass('iOver');
		}
	,
		function(){
			$(this).removeClass('iOver');
		}
	);
})
</script>
<style type="Text/Css">
	.iOver
	{
		background-Color:yellow;
		color:blue;
	}
	.iOut
	{
		background-Color:white;
		color:black;
	}
</style>
</HEAD>
<BODY>
<FORM action="" method=POST id=form1 name=form1>
<div>這是第1個div</div>
<div>這是第2個div</div>
<div>這是第3個div</div>
<div>這是第4個div</div>
<table>
	<thead>
		<tr>
			<th>aaa</th>
			<th>aaa</th>
			<th>aaa</th>
		</tr>
	</thead>
	<tbody id="myBd">
		<tr>
			<td>dddd</td>
			<td>dddd</td>
			<td>dddd</td>
		</tr>
		<tr>
			<td>dddd</td>
			<td>dddd</td>
			<td>dddd</td>
		</tr>
		<tr>
			<td>dddd</td>
			<td>dddd</td>
			<td>dddd</td>
		</tr>
		<tr>
			<td>dddd</td>
			<td>dddd</td>
			<td>dddd</td>
		</tr>
		<tr>
			<td>dddd</td>
			<td>dddd</td>
			<td>dddd</td>
		</tr>
	</tbody>
</table>
</FORM>
</BODY>
</HTML>
以下是簽名:
- 歡迎轉貼本站的文章,不過請在貼文主旨上加上【轉貼】,並在文章中附上本篇的超連結與站名【topcat姍舞之間的極度凝聚】,感恩大家的配合。
- 小喵大部分的文章會以小喵熟悉的語言VB.NET撰寫,如果您需要C#的Code,也許您可以試著用線上的工具進行轉換,這裡提供幾個參考
| Microsoft MVP Visual Studio and Development Technologies (2005~2019/6) | topcat Blog:http://www.dotblogs.com.tw/topcat | 
