Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8137969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:20:55+00:00 2026-06-06T11:20:55+00:00

I just created my first jQuery plugin , it is very simple it slideToggle

  • 0

I just created my first jQuery plugin , it is very simple it slideToggle two Divs , the code works fine and it do what i want , the problem is that i get an ERROR message at the console saying :

Uncaught TypeError: object is not a function  

it refer to this line of code

})(jQuery);

CODE

   $(function($) {
            $.fn.toggleDiv = function(opt) {
                var options = $.extend({}, $.fn.toggleDiv.objectOptions, opt);
                return this.each(function() {
                    if (options.animation == true) {
                        $(this).slideToggle();

                    } else {
                        $(this).toggle();

                    }
                });
            };

            $.fn.toggleDiv.objectOptions = {
                animation: false
            };
            $("button").click(function() { $("#Div1, #Div2")
             .toggleDiv({animation : fa}); return false; });
        })(jQuery);  

Does any one know what is that error and how can i fix it thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:20:57+00:00Added an answer on June 6, 2026 at 11:20 am

    You either want to do

    (function ($) { ... })(jQuery);
    

    if you want your code to be run immediatly,

    or

    jQuery(function ($) { .... });
    

    for your code to be run on document-ready.

    You are referring to $(“button”), and therefore need the document tree to be available. So use the second version. A even nicer solution would be to use the jQuery function “delegate”, this would look something like this:

    jQuery(function ($) {
        $(document).delegate("button", "click", function (ev) { ... });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just created my first rss feed. it worked fine. got it validated. It
First of all I'm not interested of using some jquery plugin . I just
I just created my first MVC2 project using the standard template. I need to
I have just created my first Rightscale ServerTemplate and Deployment using a bunch of
I had a guy created a jquery plugin for me. Basically, it was 5
i'm trying to create my first jQuery plugin. i got a prototype function called
Ok. First let me say that I just started learning jQuery and I've taken
I've just built my first plugin for WordPress, and even if it's not a
Bit of a newb but just having a small problem using jquery cycle all
I'm using a jquery flowplayer tools plugin http://flowplayer.org/tools/tooltip.html 1)I want a tooltip to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.