1

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);
1
  • Would you mind posting some additional information? E.g., Example HTML that you're traversing, and what your .each() and .click() closures are doing. Commented Mar 26, 2009 at 0:19

1 Answer 1

4

You have this snippet:

not(:first)

Try wrapping ':first' in quotes.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Ron. That's cleared up the syntax errors, but for some reason nothing within the .click()(function(){ is being called. Is my syntax there correct? There are definately s to find.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.