Jquery Self Invoking Anonymous Function

This Is A Simple Jquery slideToggle Using A self Invoking Anonymous Function Instead Of Document Ready Please Discus The Advantages And Disadvantages Of This.

Hope this helps you, please leave comments below on how to improve this or just to say Hi.

Result Click On The Headers

Heading 1


Heading 2


Heading 3


Heading 4

 <!doctype html>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  <div id="accordion">
  <h2>Heading 1</h2>
  <h2>Heading 2</h2>
  <h2>Heading 3</h2>
  <h2>Heading 4</h2>
  <script type="text/javascript">
  (function() {
  var headers = {
  init: function( config ) {
  this.config = config;
  bindEvents: function() {
  this.config.header.on('click', this.toggle);
  $("#accordion div").hide();
  toggle: function(){
  header: $("#accordion h2")

Available For Freelance:

I Am Available To Work For You Freelance, See My Skills To See If I Can Help Your Project, If I Can Help You Then Please Contact Me.

My Rates Start From £180 A Day, Discount Prices For Regular Clients And Work Over 3 Days.

I Started To Learn Web Development In 2008, I Did A Few Open University Courses While Working Full Time In The Building Trade, I Managed To Get A Diploma With Distinction

Request A Tutorial

If You Are Having Difficulty With The Development Of Your Website Or If You Are Just Starting Out Leaning Web Development And You Think I Can Help You Then Request A Tutorial, I Will Do My Best To Help You

I Dont Charge For My Services If I Can Help You With Something That Can Be Be Fixed In A Few Minutes.


If You Would Like To Advertise On This Site Then Please Contact Me, You Will Be Given Login Details To See What Day And Where Clicks Have Come From.

Prices Start From £10 A Month With Discounts Available For 3 Months Or More.

You Can Either Send Me The Banner Advert That You Have Designed Or From £10 I Can Have Designer Design A Banner For You.

Please Leave A Comment And A Rating


Chris Gave This Code Rating

A Jquery slideToggle using A Self Invoking Anonymous Function Instead Of Document Ready, please discus the advantages and disadvantages of this

www.codecaven.co.uk image 5.00 out of 5 based on 1 ratings. 1 user reviews.

My Skills:

  • PHP 5
  • JavaScript
  • Jquery
  • XHTML Validation
  • KineticJS
  • HTML5
  • CSS - CSS3
  • SEO

My Social Networks:

  • facebook youtube