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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script src="js/jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(function(){ $("#btn1").toggle(function(){ $("#div2").animate({left:"300px"},500); $("#div1").animate({left:"0px"},500); $("#div2").animate({left:"-300px"},10); },function(){ $("#div1").animate({left:"300px"},500); $("#div2").animate({left:"0px"},500); $("#div1").animate({left:"-300px"},10); }) }) </script> <style type="text/css"> #outer{ position:relative; width:600px; height:200px; overflow:hidden; background-color:#999; } #div1{ position:absolute; width:300px; height:200px; top:0px; left:-300px; } #div2{ position:absolute; width:300px; height:200px; top:0px; left:0px; } </style> </head> <body> <div id="outer"> <div id="div1"> <img src="img/范筱梵-1024x768.jpg" width="300" height="200" /> </div> <div id="div2"> <img src="img/美女高清壁纸【第二期】 (2).jpg" width="300" height="200" /> </div> </div> <input type="button" value="开始" id="btn1"/> </body> </html>
希望本文所述对大家的jquery程序设计有所帮助。
本文地址:http://www.45fan.com/bcdm/17279.html