- <html>
- <head>
- <script src1="jquery.js">
- </script>
- <script>
- function swapImages(){
- var $active = $('#myGallery .active');
- var $next = ($('#myGallery .active').next().length > 0) ? $('#myGallery .active').next() : $('#myGallery img:first');
- $active.fadeOut(function(){
- $active.removeClass('active');
- $next.fadeIn().addClass('active');
- });
- }
- $(document).ready(function(){
- // Run our swapImages() function every 5secs
- setInterval('swapImages()', 5000);
- }
- </script>
- <style>
- #myGallery{
- position:relative;
- width:400px; /* Set your image width */
- height:300px; /* Set your image height */
- }
- #myGallery img{
- display:none;
- position:absolute;
- top:0;
- left:0;
- }
- #myGallery img.active{
- display:block;
- }
- </style>
- </head>
- <body>
- <div id="myGallery">
- <img src1="image1.jpg" class="active" />
- <img src1="image2.jpg" />
- <img src1="image3.jpg" />
- </div>
- </body>
- </html>
- //该片段来自于http://www.codesnippet.cn/detail/050320132305.html
来源: http://www.codesnippet.cn/detail/050320132305.html