a have a bootstrap collapse with a button inside the header. On the button is clickEvent
 
I want to prevent the collapseEvent when clicking the button. Does anyone have a tipp?
This does not help here
$('#buttonId').live("click", function (e) {
    e.preventDefault();   
    // some action ...
});
Is there a way to prevent the default collapse action?
Thx
To control (show/hide) the collapsible content, add the data-toggle="collapse" attribute to an <a> or a <button> element. Then add the data-target="#id" attribute to connect the button with the collapsible content (<div id="demo">).
If the collapsible element is closed by default, the attribute on the control element should have a value of aria-expanded="false" . If you've set the collapsible element to be open by default using the show class, set aria-expanded="true" on the control instead.
You can determine whether an element is collapsed or not by using the :visible and :hidden selectors. }, "slow" );
The Bootstrap accordion is a component that organizes content within collapsable items. Accordion allows the display of only one collapsed item at a time. Accordions can toggle through a number of text blocks with a single click, and that greatly enhances the UX of your project.
I think you are looking for  stopPropagation() method instead:
$('#buttonId').live("click", function (e) {
    e.stopPropagation();   
    // some action ...
});
If your button is a link  (<a> tag ), you should prevent default too or use return false;
BTW, live is deprecated, you should use .on() delegation syntax instead, e.g:
$(document).on('click', '#buttonId', function(e){
    e.stopPropagation(); 
    // some action ...
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With