简体   繁体   中英

Bootstrap change button color

Hi I am using the script, which changes the "On" to "Off"

but I also want the button color to change so "btn-primary" to faded color.

using the "disabled" fades the color but makes the button unclickable.

<script>
$('.onbtn, .onbtn').click(function() {
    $(this).toggleClass('onbtn onbtn');
    var text = $(this).text();
    $(this).text(text == "On" ? "Off" : "On");
});
</script>

What would I have to change?

I just copied the style of the "disabled button" from bootstrap and edit it for this new class "faded".

  .faded {
    filter: alpha(opacity=65);
    -webkit-box-shadow: none;
    box-shadow: none;
    opacity: .65;
  }

Is this how you want it ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM