Hi

No, I mean that if you call bind() on the document, you only add the
event handler to the document. Not to every element in it.
The reason it reacts to a click everywhere is "event bubbling" (google
it).

I said that you should bind to the document, and then, inside the
function, figure out whether the clicked element is a textarea and if
it's not... then do w/e you need to do.

$(document).bind('click', function(e){
   if( e.target.nodeName == 'TEXTAREA' )
         return;
   // do stuff
});

Cheers

--
Ariel Flesler
http://flesler.blogspot.com

On 11 jun, 04:51, nandu <[EMAIL PROTECTED]> wrote:
> On Jun 10, 11:21 pm, Ariel Flesler <[EMAIL PROTECTED]> wrote:
>
> > When you bind the document, you just bind the document, not all its
> > elements. So you can't unbind afterwards.
>
> > You need to use conditions (.is() to skip clicks on textareas from
> > that handler.
>
> > if( this.nodeName == 'TEXTAREA' ) // or $(this).is('textarea')
> >     return;
>
> > --
> > Ariel Fleslerhttp://flesler.blogspot.com
>
> Dear Ariel,
>
> Thank you for your reply but I do not quite understand. Do you mean to
> say that I can skip the click handler on selected elements
> while it is bound to the entire document because I cannot see anyway
> to do that.
>
> Alternatively do you mean that I should find every single element on
> the document and then bind the click handler to each one skipping
> textareas.
>
> Could you please enlighten me because I still feel a bit lost.
>
> Thanks,
>
> Nandu

Reply via email to