方法一:

<!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>无标题文档</title>
<title>无标题文档</title>
<style type="text/css">
#tu
{
width:400px;
float:left; }
#a,#b,#c,#d,#e,#f,#g
{
width:500px;
height:350px;
float:left;
float:left;
}
</style> </head>
<body>
<div id="tu">
<img id="a" src="207.jpg" style="display:block"/>
<img id="b" src="t01ba56e06b53e9d8ba.jpg" style="display:none"/>
<img id="c" src="1.gif" style="display:none"/>
<img id="d" src="3-1.jpg" style="display:none"/>
<img id="e" src="TFMW20150411_Yale_0022_NEW_Rotator.jpg" style="display:none"/>
<img id="f" src="t01ba56e06b53e9d8ba.jpg" style="display:none"/>
<img id="g" src="TFMW20150411_Yale_0022_NEW_Rotator.jpg" style="display:none"/>
</div>
</body>
<script type="text/javascript">
var jihe=new Array();
jihe[]=document.getElementById("a");
jihe[]=document.getElementById("b");
jihe[]=document.getElementById("c");
jihe[]=document.getElementById("d");
jihe[]=document.getElementById("e");
jihe[]=document.getElementById("f");
jihe[]=document.getElementById("g"); var n=;
function change()
{
n++;
if(n==)
{
jihe[].style.display="block";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none"; }
else if(n==)
{
jihe[].style.display="none";
jihe[].style.display="block";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
}
else if(n==)
{
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="block";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
}
else if(n==)
{
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="block";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
}
else if(n==)
{
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="block";
jihe[].style.display="none";
jihe[].style.display="none";
}
else if(n==)
{
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="block";
jihe[].style.display="none";
}
else if(n==)
{
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="none";
jihe[].style.display="block";
}
else
{
n=;
}
window.setTimeout("change()",); }
window.setTimeout("change()",);
</script>
</html>

方法二:

<!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>无标题文档</title>
<style type="text/css">
#tu
{
width:400px;
float:left; }
#a,#b,#c,#d,#e,#f,#g
{
width:500px;
height:350px;
float:left;
float:left;
}
</style>
</head>
<body>
<div id="tu">
<img id="a" src="042815_Nano_468_605.jpg" style="display:block"/>
<img id="b" src="RadArt1_922.jpg" style="display:none"/>
<img id="c" src="zebrafish-522_0.jpg" style="display:none"/>
<img id="d" src="Wheat-original_605.jpg" style="display:none"/>
<img id="e" src="TFMW20150411_Yale_0022_NEW_Rotator.jpg" style="display:none"/>
<img id="f" src="t01ba56e06b53e9d8ba.jpg" style="display:none"/>
<img id="g" src="TFMW20150411_Yale_0022_NEW_Rotator.jpg" style="display:none"/>
</div>
</body>
<script type="text/javascript">
var jihe=new Array();
jihe[]=document.getElementById("a");
jihe[]=document.getElementById("b");
jihe[]=document.getElementById("c");
jihe[]=document.getElementById("d");
jihe[]=document.getElementById("e");
jihe[]=document.getElementById("f");
jihe[]=document.getElementById("g"); var n=;
function change()
{
n++;
if(n==)
{
n=;
} hideall(jihe);
jihe[n].style.display="block"; window.setTimeout("change()",); }
function hideall(a)
{
for(var i=;i<;i++)
{
a[i].style.display="none";
}
}
window.setTimeout("change()",);
</script> </html>

方法三:老师版

<!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>无标题文档</title>
</head> <body>
<div id="d" style="background-image:url(3-1.jpg); height:200px; width:200px;"></div>
</body>
<script type="text/javascript">
var img=new Array();
img[]="url(042815_Nano_468_605.jpg)";
img[]="url(RadArt1_922.jpg)";
img[]="url(zebrafish-522_0.jpg)";
img[]="url(TFMW20150411_Yale_0022_NEW_Rotator.jpg)";
img[]="url(t01ba56e06b53e9d8ba.jpg)"; var n=;
function change()
{
if(n==)
{
n=;
}
else
{
n++;
}
document.getElementById("d").style.backgroundImage=img[n];
window.setTimeout("change()",);
}
window.setTimeout("change()",); </script>
</html>

HTML——JAVASCRIPT练习题——图片轮播的更多相关文章

  1. javascript 实现图片轮播和点击切换功能

    图片轮播是网页上一个比较常见的功能,下面我们来实现他吧 原理很简单: 1:固定的区域,所有的图片重叠,一次只能显示一张图片 2:通过改变图片的zIndex属性改变显示的图片,就可以达到切换的效果了 & ...

  2. JavaScript实现图片轮播组件

    效果: 自动循环播放图片,下方有按钮可以切换到对应图片. 添加一个动画来实现图片切换. 鼠标停在图片上时,轮播停止,出现左右两个箭头,点击可以切换图片. 鼠标移开图片区域时,从当前位置继续轮播. 提供 ...

  3. 原生Javascript实现图片轮播效果

    首先引入js运动框架 function getStyle(obj,name){ if(obj.currentStyle){ return obj.currentStyle[name]; } else{ ...

  4. Bootstrap3.0学习第二十六轮(JavaScript插件——图片轮播)

    详情请查看http://aehyok.com/Blog/Detail/32.html 个人网站地址:aehyok.com QQ 技术群号:206058845,验证码为:aehyok 本文文章链接:ht ...

  5. JavaScript实现图片轮播图

    <!DOCTYPE html><html> <head> <script > var time; function init(){ //设置定时操作 t ...

  6. 纯javaScript、jQuery实现个性化图片轮播

    纯javaScript实现个性化图片轮播 轮播原理说明<如上图所示>: 1. 画布部分(可视区域)属性说明:overflow:hidden使得超出画布部分隐藏或说不可见.position: ...

  7. Javascript和jQuery WordPress 图片轮播插件, 内容滚动插件,前后切换幻灯片形式显示

    用于在有限的网页空间内展示一组产品图片或者照片,同时还有非常吸引人的动画效果.本文向大家推荐12款实用的 jQuery 图片轮播效果插件,帮助你在你的项目中加入一些效果精美的图片轮播效果,希望这些插件 ...

  8. html+css+javascript实现简易轮播图片

    html: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <lin ...

  9. JavaScript对象(document对象 图片轮播)

    图片轮播: 需要注意的HTML需要img标签,他和input标签一样,是非封闭的标签 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tran ...

随机推荐

  1. sybase用户管理(创建、授权、删除)

    一.登录用户管理:1.创建用户:sp_addlogin loginame, passwd [, defdb] [, deflanguage] [, fullname] [, passwdexp] [, ...

  2. php错误日志级别

    ; E_ALL             所有错误和警告(除E_STRICT外) ; E_ERROR           致命的错误.脚本的执行被暂停. ; E_RECOVERABLE_ERROR   ...

  3. apache 开启压缩功能

    apache如何开启压缩功能. 1,首先先确认是安装deflatte模块.如果未安装,可以重新编译apache添加参数--enable-deflate=shared ,或者扩展安装deflate模块, ...

  4. SQL创建登陆用户和赋予权限

    主要针对Sql server 2005及以上,创建简单用户名和密码所引起的密码简单的问题.解决方案 CHECK_POLICY = OFF; --强制密码策略 use MusicStore --创建登陆 ...

  5. 求1+2+3+...+n的值,要求不能使用乘除法,for、while、if、else、switch、case、等关键字及条件判断语句(JAVA)

    采用递归和三目表达式注意红色字体一定不能写成n-- 1 package com.hunag; public class Sum { static int sum; public static int ...

  6. java中关于String 类型数据 的存储方式

    Constant Pool常量池的概念: 在讲到String的一些特殊情况时,总会提到String Pool或者Constant Pool,但是我想很多人都不太 明白Constant Pool到底是个 ...

  7. BestCoder 2nd Anniversary 1001 Oracle

    找到最小的非零数字拆开来相加. 高精度. #include <iostream> #include <cstdio> #include <cstring> #inc ...

  8. VS C4819 编译错误解决方法

    偶尔用别人的代码,出现: warning C4819: The file contains a character that cannot be represented ). Save the fil ...

  9. C++标准库之泛型算法

    本文中算法都是指泛型算法. 基本要点: 1)算法使用迭代器进行操作. 2)不依赖容器,但容器希望使用算法,就必须提供接口. 3)通用算法永远不会执行容器操作.操作仅指:更改容器大小的操作.但,容器内部 ...

  10. 切记ajax中要带上AntiForgeryToken防止CSRF攻击

    在程序项目中经常看到ajax post数据到服务器没有加上防伪标记,导致CSRF被攻击,下面小编通过本篇文章给大家介绍ajax中要带上AntiForgeryToken防止CSRF攻击,感兴趣的朋友一起 ...