title: How to prevent accordion from toggling when button in header is clicked?
body: <p>I'm using bootstrap's accordion class and want to have buttons in the header that can be clicked without toggling the accordion. Here's example HTML:</p>
  
  <pre><code>&lt;div class="body"&gt;
      &lt;div class="panel panel-default" style="width: 80%"&gt;
          &lt;div class="panel-heading" data-toggle="collapse" data-target="#container1" style="cursor: pointer;"&gt;
              &lt;h4 class="panel-title" style="display: inline-block;"&gt;
                 title
              &lt;/h4&gt;
          &lt;div style="float: right; width: 130px; text-align: right;"&gt;&lt;span style="color: red;"&gt;test&lt;/span&gt;&lt;/div&gt;
              &lt;button type="button" class="btn btn-xs btn-primary" style="float: right;" onclick="foo(event);"&gt;Button&lt;/button&gt;
      &lt;/div&gt;
      &lt;div id="container1" class="panel-collapse collapse"&gt;
          &lt;div class="panel-body"&gt;
              panel content
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I tried using an <code>onclick</code> handler with <code>e.preventDefault();</code> to stop the accordion from triggering, but it didn't work:</p>
  
  <pre><code>window.foo = function(e) {
      console.log("foo");
      $(".body").append("&lt;br&gt;foo");
      e.preventDefault();
  }
  </code></pre>
  
  <p><a href="http://jsfiddle.net/Bye8K/2/" rel="noreferrer">JSFIDDLE</a></p>
  
  <p>How can I prevent the accordion from triggering when the button is clicked?</p>