DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> jQuery入門知識 >> JQuery特效代碼 >> 使用jQuery同時控制四張圖片的伸縮實現代碼
使用jQuery同時控制四張圖片的伸縮實現代碼
編輯:JQuery特效代碼     
代碼 代碼如下:
<!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>
<title></title>
<style type="text/css">
.imgclass
{
height:200px;
width:200px;
}
.imgclass1
{
width:210px; height:210px;
}
table tr td
{
width:250px; height:250px;
}
</style>
<script src="jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#Button1').click(function () {
// 獲取的是所有類型(tagname)為img的元素
// $('img').show(3000);
// $('img').hide(3000);
// //獲取的是所有class屬性的值為“imgclass”的元素
// $('.imgclass').hide(3000);
// $('.imgclass').show(3000);
// $("#img1, #img2, #Button1").hide(2000);
// $("#img1, #img2, #Button1").show(2000); //一定是將所有id用一對''括起來,而不能每個id分別用引號括起來
// //多個選擇器既可以是id,也可以是id,tagname和classname的混合體
// $("#img1, #img2, input").hide(2000);
// $("#img1, #img2, input").show(2000);
//改變圖片樣式
$('#Button2').click(function () {
// $('#img2').removeClass();//刪除Id為img2的class樣式
$('#img2').addClass('imgclass1');//然後再添加一個樣式,再次點擊按鈕操作圖片時,由於此圖片的樣式已改,所以不發生變化
})
})
})
</script>
</head>
<body>
<table>
<tr><td><img alt="" id="img1" src="images/1.jpg" class="imgclass" /></td><td><img alt="" id="img2" src="images/2.jpg" class="imgclass" /></td></tr>
<tr><td><img alt="" id="img3" src="images/3.jpg" class="imgclass" /></td><td><img alt="" id="img4" src="images/4.jpg" class="imgclass" /></td></tr>
<tr><td></td><td>
<input id="Button1" type="button" value="點我啊" /></td></tr>
<tr><td></td><td> <input id="Button2" type="button" value="改變控件樣式" /></td></tr>
</table>
</body>
</html>
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved