[jQuery] Re: Click event outside of an element

2009-12-03 Thread Keysher
Umm, It seems fine, I'll check it later. Thanks! On 23 nov, 15:13, Dustan wrote: > Perhaps something along these lines is what you are looking for? > > $(document).click(function(event) { >     if (!$(event.target).hasClass('classname')) { >         // run this code if anywhere in the document e

[jQuery] Re: Click event outside of an element

2009-11-23 Thread Dustan
Perhaps something along these lines is what you are looking for? $(document).click(function(event) { if (!$(event.target).hasClass('classname')) { // run this code if anywhere in the document except the item is clicked } }); On Nov 20, 8:29 am, Keysher wrote: > Hi! > > I am newbi

[jQuery] Re: Click event outside of an element

2009-11-22 Thread Keysher
Works fine! Thanks!! :o) On 21 nov, 15:29, mofle wrote: > Here you go: > > $(document).click(function(){ >         alert('clicked outside classname'); > > }); > > $('.classname').click(function(e){ >         e.stopPropagation(); > > }); > > First you bind a click event to the document with the a

[jQuery] Re: Click event outside of an element

2009-11-21 Thread mofle
Here you go: $(document).click(function(){ alert('clicked outside classname'); }); $('.classname').click(function(e){ e.stopPropagation(); }); First you bind a click event to the document with the action you want. Then you bind the classname to stop it from propagate up to the d