0

How to code javascript so that the image keep changing from one to other in particular interval of time?

15th Nov 2016, 1:31 AM
Arjun
7 Respuestas
+ 1
you must use setIntervall function with DOM
15th Nov 2016, 3:01 AM
Maurizio Urso
Maurizio Urso - avatar
+ 1
use setInterval() method to run a function at specific interval. and in that function write code for changing the image
15th Nov 2016, 3:10 AM
P Sandesh Baliga
P Sandesh Baliga - avatar
+ 1
post your code so we can help you
15th Nov 2016, 3:11 AM
Maurizio Urso
Maurizio Urso - avatar
+ 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>
15th Nov 2016, 3:21 AM
Arjun
+ 1
try setInterval(function (){a();},3000); and you forget id="s"
15th Nov 2016, 3:25 AM
Maurizio Urso
Maurizio Urso - avatar
0
i did try it but its not working
15th Nov 2016, 3:03 AM
Arjun
0
img has id ="s"
15th Nov 2016, 3:22 AM
Arjun