> Hi
> I'm trying to create plugin for jquery...
> I have almost everything, but when Im using my plugin on more then one
> elements then I have problem...
>


You're not getting 'this' correct.  Where you set 'b', 'this' is the
jQuery object, not an element.  So 'b' is a jQuery object that wraps
three dom elements.  Here's a hint:

(function($) {
    $.fn.test2 = function(color) {
        // 'this' is the jQuery object
        return this.each(function() {
            // 'this' is a DOM element
            var $el = $(this);
            $el.bind('click', function() {
                // this is the DOM element again
                $el.css('color',color);
            }
        }
    }
})(jQuery);

Reply via email to