please check http://jsfiddle.net/w3father/4Z7pe/
i want to show tabs content when user click (without time delay) but auto play ne开发者_如何学编程ed time delay
Follow these points:
- implement a local variable for userInteraction
- set this variable to true if the user clicks your links
- if this variable is true your interval method should do? -> nothing!
- stop all happening animations and minimize every tab instead of the clicked
I think those ideas should help. If you have further questions, just ask.
Try to seperate the code a little bit more. Javascript is object-orientated aswell!
/edit:
Let me abstract this a little bit for you:
var currTab;
var userInteraction;
function intervalAction() {
if (userInteraction) return;
else showTab(currTab++);
}
function showTab(tab) {
// stop running animations
// hide every tab
// show the tab that is wanted
}
Use the code you've already written and place it inside. Upload it to jsfiddle again and let me see your results.
精彩评论