0
How to code javascript so that the image keep changing from one to other in particular interval of time?
7 Réponses
+ 1
you must use setIntervall function with DOM
+ 1
use setInterval() method to run a function at specific interval. and in that function write code for changing the image
+ 1
post your code so we can help you
+ 1
<img src="1.jpg">
<script>
function a(){
var x= document.getElementById("s");
x.src ="2.jpg";
}
function b(){
var y = document.getElementById("s");
y.src="1.jpg"
}
setInterval(a,3000);
setInterval(b,7000);
</script>
+ 1
try
setInterval(function (){a();},3000);
and you forget id="s"
0
i did try it but its not working
0
img has id ="s"