> 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);

http://bynight.me.uk/jquery/mike.php

Still its not okay, but...

When I use
b.bind('click', function() { b.css('color',color);}
it works fine, but when I try:

callback = function(data) {
b.css('color',color);
}
ttt= function() {
callback();
}
b.bind('click',ttt);

I have result as you see on my page...

...
To be more specific...
I want use my plugin like that:
callback = function() { ...}
$('#something').test('option',callback);
or $('#something').test('option',function() {...});

thats why I want to have my function (ttt or callback) outside of
b.bind(..)

Thanks.
Michael

Reply via email to