欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

jquery实现图片渐变切换兼容ie6/Chrome/Firefox

程序员文章站 2022-05-02 12:14:29
代码如下:

代码如下:


<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "https://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="author" content="nancle from cau cs101" />
<title>jquery图片渐变切换</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<style type="text/css">
ul{position:relative;}
ul li{display:block; position:absolute; left:0; top:0}
img{width:480px; height:320px; border:5px solid #ccc}
</style>
</head>
<body>
<ul>
<li><img src=https://www.2cto.com/uploadfile/2018/0414/20180414015957532.jpg" /></li>
<li><img src=https://www.2cto.com/uploadfile/2018/0414/20180414015957761.jpg" /></li>
<li><img src=https://www.2cto.com/uploadfile/2018/0414/20180414015957611.jpg" /></li>
<li><img src=https://www.2cto.com/uploadfile/2018/0414/20180414015957645.jpg" /></li>
</ul>
</p>
<script>
var switchspeed = 1000; //图片切换时间
var fadespeed = 1500; //渐变时间
setinterval(function(){
$('img').last().fadeout(fadespeed, function(){
$(this).show().parent().prependto($('ul'));
});
}, switchspeed);
</script>
</body>
</html>