You can do :
$(document).bind('click', function(e){
var $clicked = $(e.target);
if (!($clicked.is('#element') ||
$clicked.parents().is
('#element'))) {
//click
Thanks, Sam! I had to make one change, then it worked.
I got an error message that event was undefined, so I changed the
first line from:
$(document.body).click(function(){
to
$(document.body).click(function(event){
Gotta tell ya, when I hear the phrase event delegation my head
starts to hurt.
Hmmm, I wasn't able to find anything about that, though I checked only
quickly. What section fo the docs would that be in?
On Jan 13, 5:44 pm, Kean shenan...@gmail.com wrote:
You might want to look at live and die method now posted in jQuery
documentation.
On Jan 13, 11:32
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
You might want to look at live and die method now posted in jQuery
documentation.
On Jan 13, 11:32 am, 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
5 matches
Mail list logo