I have a javascript code here that on click one pulls one function and on click 2 pulls another function.
How can i make it so after X amoutn of seconds if i am on stop_autoslide function that i can call start_autoslide?
<script>
var count = 0;
function function1(){
stop_autoslide()
count++;
}
function function2(){
start_autoslide();
count = 0;
}
function slideShowClicks(){
if(count ==0){
function1();
}else{
function2();
}
}
</script>
您setInterval函数。
setInterval(function_name, time_in_milli_sec);
var t = setTimeout(function2, 2000);
This will call function2 after 2s (2000ms).
You can then use t
to cancel the timeout, etc.
Edit:
function function2(){
start_autoslide();
var t = setTimeout(function2, 2000);
}
This way, function2()
will get executed every 2 seconds after you call it from slideShowClicks()
the first time.
add to your stop_autoslide()
function
var timeout=setTimeout("start_autoslide()",3000);
replace 3000 it 3 sec
with amount of sec you want
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.