Q:

How to create an if statement for jQuery, click event

I do have a css class name ".className"
How to create an if statement wherein if the user does not click .className it will alert.
for example:
if (click != $('.className')) {
   alert("You did not click className");
}

I know that my code is incorrect. How to do it? Btw, this is similar to an outside click.
Thank you.

A:

$("a").click(function(e) {
    e.preventDefault();
    if (!$(this).hasClass('className')) {
        alert("You did not click className!");
    }
});

demo: http://jsfiddle.net/yaqLs/

EDIT: If by "outside clicks" you mean not just links then,
$("*").click(function(e) {
    e.stopPropagation();
    if (!$(this).hasClass('className')) {
        alert("You did not click className!");
    }
});

demo: http://jsfiddle.net/yaqLs/1/

