I have a dilemma with my two buttons - one is green and the other has no background. I want them to change appearance when clicked, from green to one with a dashed border-bottom style.
Below is the HTML code for these buttons:
<div class="btns">
<button type="button" class="btn btn-success">Male</button>
<button type="button" class="btn btn-link btn-simple">Female</button>
</div>
I attempted to write a script to achieve this functionality:
$('.btn').click(function() {
var $this = $(this);
if ($this.hasClass('btn-success')) {
$this.removeClass().addClass('btn-simple');
} else if ($this.hasClass('btn-simple')) {
$this.removeClass('btn-simple').addClass('btn-success');
}
});
Unfortunately, it seems that the script is not working as expected.
In addition, here is the CSS styling added for the button with the dashed border effect:
.btn-simple {
border-bottom: 1px dashed #000;
color: #000;
}
No other additional styles were applied since these buttons are utilizing Bootstrap styling.