jquery實現圖片放大效果
阿新 • • 發佈:2017-10-18
jquery實現圖片放大效果
好久沒更新了,先來一發關於jquery圖片放大縮小的代碼
直接上代碼
前端頁面:
<tr> <td height="30" align="right" bgcolor="#f2f2f2" class="left_txt2">產品相冊</td> <td bgcolor="#f2f2f2"> </td> <td width="32%" height="30" bgcolor="#f2f2f2" class="goodsimgupload"> <span id="uploadPercent"></span> <input type="hidden" value="<?php echo $result[‘goodsimg‘];?>" name="goodsimg" /> <img src=\‘#\‘" /td> </tr>
$(function (){ var isbig = -1;//定義全局變量 判斷放大縮小 自己發揮的寫吧 $(".img").click(function(){ if(isbig == -1) { $("#img_id").animate({height: "300px", width: "300px"}); isbig = 1; }else{ $("#img_id").animate({height: "50px", width: "100px"}); isbig = -1; } }); });
本文出自 “kangjunfei” 博客,轉載請與作者聯系!
jquery實現圖片放大效果