Home  >  Article  >  Web Front-end  >  js picture flashing special effect can control the interval time, such as flashing in a few minutes_javascript skills

js picture flashing special effect can control the interval time, such as flashing in a few minutes_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:39:481315browse

As soon as the picture comes out, it will start flashing after 5 seconds, and then stop.

var inter={};
var i=0;
$(document).ready(function(){
$("a").each(function(index,item){
$(this).bind().click(function(){
i=index;
if(inter!=null || inter.length>0){
window.clearInterval(inter);
}

window.setTimeout(function(){
inter=window.setInterval(function(){ $("img").eq(i).show().fadeOut(100).fadeIn(100);},500);
window.setTimeout(function(){
window.clearInterval(inter);
},5000);
},5000);

});

});
window.setTimeout(function(){
inter=window.setInterval(function(){ $("img").eq(i).show().fadeOut(100).fadeIn(100);},500);
window.setTimeout(function(){
window.clearInterval(inter);
},5000);
},5000);
});
Statement:
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