On 4 Feb, 16:15, Giovanni Battista Lenoci <[EMAIL PROTECTED]> wrote:
> I was making some test, and I have little problem..
>
> If I bind a function to an element with jquery style method:
>
> $('#target').bind('click', function() { dosomething(this); ) });
>
> in my dosomething function I can retrieve the element clicked.
>
> With your syntax I can bind/unbind function but I can't call dosomething
> with this parameter.

look at my code:

var clickFn = function(){
        alert("ctrl + click");
        $(this).unbind('click', clickFn);
}

you can still get what you need by using $(this) in the function
for example:

var $this = $(this);
dosomething($this);

naming the function is useful if your #target element has other
functions bound to a click event.
in that case doing a simple
$("#target").unbind('click');
would unbind even functions you may want to keep.

> Thank you..

figurati, you're welcome :)

Reply via email to