What you're describing is a pattern called "event delegation."  It is
actually quite efficient, since you don't have to bind an event to
each object, but rather 1 event to a larger object:

$(document.body).click(function(){
    var target = $(event.target);
    if (target.is("#foo")){
       //its foo!
    }
});

More info on event delegation:

http://docs.jquery.com/Events/jQuery.Event

-sam

On Jan 13, 2:32 pm, riotbrrd <k...@riotbrrd.com> wrote:
> Hi all,
>
> Is there a simple way to capture a click event in a window/document
> and then determine whether the click was inside an element #foo, or
> outside of that element?
>
> Thanks!
> -Kim

Reply via email to