I recently started to work on my first plugin but i am stuck a little. My problem is that after my plugin starts I don't know how to stop it. And by stop it I mean: when I click on a #div the plugin stops and when I click on it again it starts:
Something like this:

What do you mean by "stop the function"? Also, we're not here to write improvements to your code; you should be doing that.
–
BojanglesNov 28 '11 at 21:08

What is your plugin meant to do exactly?
–
Brian DriscollNov 28 '11 at 21:09

Also, your fiddle only contains your plugin's code and no sample use case, which would help a lot in understanding your question, as vague as it is.
–
Frédéric HamidiNov 28 '11 at 21:09

3

You guys are way too quick to close a question. His method started an interval timer and the OP needed to know how to store that timer handle and stop it later. I was about to provide an answer to the question, but you all closed it so quick (in less than 7 mins) that now it won't take my answer. Yes, the question was not very clearly written, but if you just look at the referenced code, you would understand what stop meant in the context of the question/code.
–
jfriend00Nov 28 '11 at 21:17

2

@FrédéricHamidi - When I say "way too quick to close a question", I was voicing that to everyone who voted to close in the first few minutes of the question without even bothering to look at the referenced code to understand what was being asked. When clarifying questions have been asked, it seems reasonable to allow some amount of time for the OP to respond before immediately voting to close. The newer the OP, the more time might be appropriate since they might not know to be watching for the immediate comments. It was a poorly worded question, but it was understandable with a little work.
–
jfriend00Nov 28 '11 at 21:38

Thank you for your help but by 'stop the function' I mean when I click on a #div the plugin stops and by clicking on it again it will run again. sorry for the misunderstanding but iam a jQuery noob.
–
nmsdvidNov 28 '11 at 22:43

1

@nmsdvid - the confusion has nothing to do with your jQuery knowledge. You have not yet described the problem in a clear fashion. You need to go back to your question, use the edit button and tell us how it is supposed to work. What is supposed to happen on the first click? What is supposed to happen on the interval timer? How long is the interval timer supposed to run? What is supposed to happen if it is clicked again?
–
jfriend00Nov 28 '11 at 23:32

@nmsdvid - I added one more option where the call the plugin() will alterate between starting and stopping so the first click will start and the second click will stop. If you want something different than that, then you have to describe a lot more clearly what you want. I'm just about done trying to guess how you want it to work.
–
jfriend00Nov 28 '11 at 23:43