Why define an anonymous function and pass it jQuery as the argument?

The two blocks of code you have shown are dramatically different in when and why they execute. They are not exclusive of each other. They do not serve the same purpose. JavaScript Modules This is a “JavaScript Module” pattern, implemented with an immediately invoking function. http://addyosmani.com/resources/essentialjsdesignpatterns/book/#modulepatternjavascript http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth The purpose of this code is to provide … Read more

How can I expand and collapse a

Okay, so you’ve got two options here : Use jQuery UI’s accordion – its nice, easy and fast. See more info here Or, if you still wanna do this by yourself, you could remove the fieldset (its not semantically right to use it for this anyway) and create a structure by yourself. Here’s how you … Read more