John Magnolia John Magnolia - 6 months ago 30
Javascript Question

Bootstrap button reset

Click the Default button to add active class but why is the reset button not resetting the button state?

$('#reset').click(function(){
$('#test').button('reset');
})


HTML

<p>
<button id="test" type="button" class="btn btn-primary" data-toggle="button" aria-pressed="false" autocomplete="off">Default</button>
</p>
<p>
<button id="reset">
Reset
</button>
</p>


Example: http://jsfiddle.net/rdh579hc/1/

Answer

You can do that to reset your button :

$('#reset').click(function() {
  var button = $('#test');
  button.attr('aria-pressed', "false");
  button.removeClass('active');
})

http://jsfiddle.net/gpfb7xeu/

Comments