title: Use stopPropagation in click event
body: <p>I have an anchor inside a div with class "element".</p>
  
  <pre><code>&lt;div class="element logout"&gt;
      &lt;div class="subTop"&gt;
          &lt;a href="home.jsp" onclick="return confirm('Do you want to logout?');"&gt;Log Out&lt;/a&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I use the following code to handle logout.</p>
  
  <pre><code>jQuery(".element").click(function(e){
      var tmpHref=jQuery(this).not('.logout').find(".subTop&gt;a").attr('href');
      if(tmpHref!=undefined&amp;&amp;tmpHref!=""&amp;&amp;tmpHref!=null)
      {
          window.location.href=tmpHref;
      }
      else
      {
          jQuery(this).find(".subTop&gt;a").click();
      }
  });
  </code></pre>
  
  <p>But my problem is the confirmation event triggers again and again. I think its because of the even propagation. After my research i find out I can use <code>e.stopPropagation()</code> from <a href="https://stackoverflow.com/questions/2364629/jquery-stop-child-triggering-parent-event">this</a> post. But I cannot figure out how could this be used here.</p>
  
  <p><strong>EDIT</strong>
  The message 'Do you want to logout?' in confirm box is dynamically taken from the database, so I cant hard code it in the code.</p>