This is a simple tip, that I thought I would clarify after spending some time scratching my head over a stupid, stupid mistake!
When you are using a switch statement make sure you are either returning or breaking at the end of a case statement. If you do not, your switch statement will run the expected case block AND the default block.
Below are a couple of GISTs showing what I mean.
The top GIST demonstrates how to do it, and the bottom shows you hoe to not do it. The main difference is that the second case block does not have a break. This means both the function ‘doSomethingElse()’ and ‘doDefault()’ will be executed. Not what we are after.
To give you a head start with developing jQuery plugins below is a small template that you can use to build your jQuery plugin around.
The above is a compilation of these two tutorials provided on the jQuery website: