TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Madhukar Krishna
688
1.4k
292.2k
Javascript: Image change not working
Mar 15 2014 2:25 PM
The following code is not working. It doesn't show any image. Please help.
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
var myVar = setInterval(function(){randim()},1000);
function randim(){
var bannerImages = new Array( );
bannerImages[0] = "1.jpg";
bannerImages[1] = "2.jpg";
bannerImages[2] = "3.jpg";
bannerImages[3] = "4.jpg";
bannerImages[4] = "5.jpg";
bannerImages[5] = "6.jpg";
bannerImages[6] = "7.jpg";
var randomImageIndex = 0;
randomImageIndex = Math.round( Math.random( ) * 6 );
}
function myStopFunction()
{
clearInterval(myVar);
}
</script>
<p>A script on this page starts this image change:</p>
<img src="\""+bannerImages[randomImageIndex]+"\"" />
<button onclick="myStopFunction()">Stop image</button>
</body>
</html>
Reply
Answers (
2
)
How to make bottom smaller
Javascript: While loop - looping forever