0

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?

3
  • Try something like $("#btn-primary").css("opacity","0.5"); Apr 16, 2014 at 8:15
  • 1
    Or just create another css class that and toggle that.
    – Insyte
    Apr 16, 2014 at 8:18
  • I like the opacity concept, how would I implement the code? I am not completely fluent in javascript. <a href="#" class="onbtn btn btn-default btn-info btn-sm">On</a> Apr 16, 2014 at 8:21

1 Answer 1

2

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 ?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.