tags:

views:

39

answers:

3

How do you exit from an event?

$('.more').click(function() {
   if (condition1) {
      if (condition2) {
         // abort, exit completely out of click handler
      ...
+4  A: 

Use the return there:

$('.more').click(function() {
   if (condition1) {
      if (condition2) {
         // abort, exit completely out of click handler
         return;

See:

Interrupting a function Safely

Web Logic
+1  A: 

return;

That will take you out of the function that is associated with the on click handler;

dalton
+2  A: 

Note that you can also use break here.

$('.more').click(function() {
   if (condition1) {
      if (condition2) {
         // abort, exit completely out of click handler
         break;
Secko