As indicated in the comments, don't rebind your event each and every time stop()
is called. Let's move that binding out, and we're also going to use stopPropgation()
so that the click event won't bubble up to the document, which will trigger the plugin to start its mojo again:
function stop(){
$("#webticker").trigger('click'); //This method doesn't provide anything, except perhaps making code a bit more readable
}
$("#webticker").click(function(event){
event.stopPropagation(); //If we don't stop propagation, the click event will bubble up to the document, which will start the ticker again
$("#webticker").webTicker('stop');
if($(event.target).is('#img1')) {
$('#log').html(event.target.id + ' was clicked.');
timer = setTimeout(contin, 1);
} else if($(event.target).is('#img2')){
$('#log').html(event.target.id + ' was clicked.');
timer = setTimeout(contin, 1);
} else if($(event.target).is('#img3')){
$('#log').html(event.target.id + ' was clicked.');
timer = setTimeout(contin, 1);
} else if($(event.target).is('#img4')){
$('#log').html(event.target.id + ' was clicked.');
timer = setTimeout(contin, 1);
} else if($(event.target).is('#img5')){
$('#log').html(event.target.id + ' was clicked.');
timer = setTimeout(contin, 1);
}
});
JSFiddle: http://jsfiddle.net/rLyyR/6/