Home > Web Front-end > JS Tutorial > JavaScript method to hide and display pictures at regular intervals_javascript skills

JavaScript method to hide and display pictures at regular intervals_javascript skills

WBOY
Release: 2016-05-16 15:46:42
Original
1551 people have browsed it

The example in this article describes how to implement timing hiding and display of images using JavaScript. Share it with everyone for your reference. The details are as follows:

JavaScript is used here to hide and display images at regular intervals. The image will be automatically displayed or hidden after a few seconds. You can define the number of seconds yourself in the JavaScript code snippet.

The operation effect is as shown below:

The specific code is as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>定时隐藏图片</title>
</head>
<SCRIPT LANGUAGE="JavaScript">
var sec=10;
var timer;
function hidepic()
{
 sec--;
 if (sec==0){
  textfield.value = "图片被隐藏";
  soccer.style.visibility =(soccer.style.visibility == "hidden") &#63; "visible" : "hidden";
 }
 else{
  textfield.value = "图片会在 "+sec+" 秒后隐藏";
  setTimeout("hidepic()",1000);
 }
}
</SCRIPT>
<body onLoad = "hidepic();">
<center>
 <input name="textfield" type="text" size="20"> <br>
 <DIV ID="soccer" STYLE="position:absolute; left:333px; top:43px">
 <img border="0" src="http://www.jb51.net/images/logo.gif" >
 </DIV>
</center> 
</body>
</html>
Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template