Witth Jquery how I can stop running a function ?

Witth Jquery how I can stop running a function ?

Example : I run the function addimagezoom() on click like this.

$("#section").click(function() {
			$('#img1').addimagezoom();		
});



$("#stop").click(function() {
		//How I can stop the addimagezoom function here by clicking on this button		
});

You can set a Boolean to true iniside your stop function and then check the value of the Boolean in your other code.

And how I do that…can you show me an example of code ?

Thanks

It sounds to me like you are trying to reverse/reset the action that got executed by this function call. Have you looked into the api?

SuperFlash said

And how I do that…can you show me an example of code ?

Thanks

var allGood = true;

$("#section").click(function() {
	$('#img1').addimagezoom();        
});

$("#stop").click(function() {
	allGood = false;     
});

function addimagezoom() {

	if(allGood) {
	
		// execute code
		
	}
	
}

I think it’s probably more complicated than this because it really depends on what you’re doing in the imagezoom function. For example, I assume it’s a function that’s being fired continuously which is why you need to its code to stop executing? If so there’s likely an interval involved that just needs to be cleared instead (the Boolean method would still technically work but clearing the interval would be much more efficient).

Ok thanks i’ll try this.

Yes I have looked at the api and there is no stop function.
I have tried to find something to stop executing the function but i found nothing.