首页 > 代码库 > 11.29

11.29

    在流程图中菱形代表判断,圆角矩形代表开始和结束,平行四边形代表内容。

    清除定时器:

function clearT()

{

clearInterval(clearTime)

}

开启定时器:

function openT()

{

clearTime = setInterval(change,2000)

}

setInterval(控制的函数,时间一般用毫秒表示)

轮播:

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title></title>

<link rel="stylesheet" type="text/css" href="http://www.mamicode.com/lunbo.css">

</head>

<body>

<div id="main">

<div id="left" onclick="houtui()"></div>

<div id="center"></div>

<div id="right" onclick="change()"></div>

</div>

<script>

var imgDiv = document.getElementById(‘center‘);

var imgBg= imgDiv.style

var number = 1

function change()

{

if(number > 3)

{

number = 1;

}

imgBg.background = ‘url(./images/‘+ number +‘.jpg)‘;

number++;

}

function houtui()

{

if(number<1)

{

number = 3

}

imgBg.background = ‘url(./images/‘+ number +‘.jpg)‘;

number--

}

var clearTime = setInterval(change,2000)

 清除定时器函数

function clearT()

{

clearInterval(clearTime)

}

 开启函数定时器

function openT()

{

clearTime = setInterval(change,2000)

}

</script>

</body>

</html>


11.29