Simply stop the parent from playing the event when the event.stopPropagation button is event.stopPropagation so that it does not trigger a click event on the accordion after the click event on the button is executed.
$thisButton.click(function(e) { e.stopPropagation();
Demo
In addition, you do not need to execute each of the selectors to bind the click event, instead just specify the selector for the click event itself
$(".btn-switch").click(function (e) { e.stopPropagation(); var $thisButton = $(this); $thisButton.toggleClass("btn-primary btn-danger"); if ($(this).hasClass('btn-danger')) { $thisButton.html('<i class="icon-remove-circle icon-white"></i> Remove'); $(this).parents('.thumbnail').find('.rental-count').val('1'); $(this).parents('.thumbnail').find('input').change(); } else { $thisButton.html('<i class="icon-ok-circle icon-white"></i> Add to Quote'); $(this).parents('.thumbnail').find('input').val(''); $(this).parents('.thumbnail').find('input').prop('checked', false); $(this).parents('.thumbnail').find('input').change(); } });
source share