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 <keys...@gmail.com> wrote:
> Hi!
>
> I am newbie in JQuery. I want to catch click event outside and
> specified class.
>
> For example, I have a div with class "classname", and I want to attach
> some actions when I click outside, in the rest of the page.
>
> I tried with this (to get the classname where I click):
>
> $('*').click(function(){
>         alert($(this).attr('class'));
>
> });
>
> But not works!
>
> Any idea?
>
> Thanks!
>
> P.D: sorry for the bad english!

Reply via email to