title: Simple jQuery click event bind not working in IE8
body: <p>This seems to work in nearly every browser except IE8 (and probably IE7, but I haven't tried that yet), and I'm not sure why.</p>
  
  <pre><code>$('body')
      .on('click', '.toggle', function(e){
          $(this).toggleClass('active');
          e.preventDefault();
          e.stopPropagation();
      });
  </code></pre>
  
  <p>I notice when I click a link classed <code>toggle</code>, the browser goes to the page top despite the <code>e.preventDefault()</code>. In looking into the problem, I've seen solutions like returning false or setting <code>event.returnValue = false</code>. I've tried both of these by first testing for <code>e.preventDefault()</code> then executing the alternative if the condition is not met.</p>
  
  <p>Setting return value:</p>
  
  <pre><code>$('body')
      .on('click', '.toggle', function(e){
          if (e.preventDefault()) {
                  e.preventDefault();
              } else {
                  e.returnValue = false;
              }
          $(this).toggleClass('active');
      });
  </code></pre>
  
  <p>I've also tried that one by setting <code>returnValue</code> on the global event object rather than the <code>e</code> passed into the bound function as was suggested in one post.</p>
  
  <p>My attempt returning false:</p>
  
  <pre><code>$('body')
      .on('click', '.toggle', function(e){
          if (e.preventDefault()) {
                  e.preventDefault();
              }
          $(this).toggleClass('active');
          return false;
      });
  </code></pre>
  
  <p>Despite all these different attempts, IE8 is taking the link's default action <em>and</em> is not toggling the class. What am I doing wrong here? I'm using jQuery 1.10.2.</p>
  
  <p><strong>Update:</strong> Got to the root of the issue. Thanks, everyone, for the help. I had conditionally included some script elements for non-IE, and this script was one of them. Returning false is doing the trick for me now. Thanks so much for pushing me in the right direction!</p>