Dave
Dave

Reputation:

jQuery plugin structure

I'm using the following as a basis for a jquery plugin but I seem to have some syntax issues from my .find onwards. The code within the click function won't get called and the class is not being applied. Can someone suggest where I may have gone wrong here please?

(function($){

        $.fn.expandCollapse = function(options){

             var opts = $.extend({}, $.fn.expandCollapse.defaults, options);

             function initialize(){

                $(this).each(function(){
                    // code
                }).find("p").click(function(){
                    // code
                }).end().not(:first).addClass(opts.c);
              }
            initialize();

            return $(this);

        };

        $.fn.expandCollapse.defaults = {
            c: "collapsed"
        };

})(jQuery);

Upvotes: 1

Views: 944

Answers (1)

Ron DeVera
Ron DeVera

Reputation: 14644

You have this snippet:

not(:first)

Try wrapping ':first' in quotes.

Upvotes: 4

Related Questions