Oh and I also wanted to add a comment to @jamy_za’s suggestion in that the following isn’t good practice:
// Insert an unordered list after the styled div
I would use this format in a plugin just in case the user is using older versions of jQuery. The ability to include an object with parameters wasn’t added until jQuery 1.4, and some people are still stuck using older versions.
Thanks Rob, I’m not a fan of the way it handles clicks while the animation is running though. I agree that it would work well for slower animations. With the speed I am running the animation at there is no way a ‘rapid clicker’ could know what he wanted to click on before the animation was complete.
Thanks for raising the performance issue too Gray, if I was to ever release this as a plugin, I would use a for loop.
@joshuanhibbert Hmm, that test does add an additional function, changing the background color, so I’m just not sure.
And now that I think about it, the recommendations from tip #1 above, shows how to optimize use of the sizzle engine which only activates when you use multiple selectors… so yeah, it’s not relevant in this case.
So at this point, I removed the background color from the jsperf and the class name only was faster, then I copied this post into the HTML to see if it’s faster with returning just one element and well the class name only was still faster… so yeah @jamy_za and you were right!
I hereby retract my last statement ;)… you learn something new everyday :P