标签:
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> <style> * { margin: 0; padding: 0 }
p { width: 400px; font-size: 30px; height: 300px; background: blue; border: solid 5px }
.top { position: fixed; right: 0; top: 300px }
.tiao { position: fixed; right: 0; top: 400px }
.stop { position: fixed; right: 300px; top: 500px } </style> </head> <body> <div class="stop"> <input type="button" value="star" onclick="t()"/> <input type="text" id="shijian"/> <input type="button" value="stop" onclick="stop()"/> </div> <div> <input type="button" value="返回顶部" onclick="fanhu()" class="top"/> <input type="button" value="跳转" onclick="tiao()" class="tiao"/>
<p>1楼</p>
<p>2楼</p>
<p>3楼</p>
<p>4楼</p>
<p>5楼</p>
<p>6楼</p>
<p>7楼</p>
<p>8楼</p>
<p>9楼</p>
<p>10楼</p>
<p>11楼</p>
<p>12楼</p>
<p>13楼</p>
<p>14楼</p>
<p>15楼</p>
<p>16楼</p>
</div> </body> <script type="text/javascript"> function fanhu() { window.scrollTo(0, 0) } function tiao() { window.scrollBy(0, 310) }
function t(){ setInterval("star()", 100); }
var i=21; function star(){ i=i-1; if(i>=0&&i<=20){ document.getElementById("shijian").value=i;
} else{ clearInterval("shijian") } } function stop(){ i=-1 } </script> </html>
标签:
原文地址:http://www.cnblogs.com/dugufeiyang/p/5495575.html