How to change the button color when it is active using bootstrap?

后端 未结 3 1177
礼貌的吻别
礼貌的吻别 2020-12-17 09:56

I am using bootstrap 3. I want to change button color when I click on button.I mean button should be in different color when it is selected. How can I do this using css?

3条回答
  •  时光说笑
    2020-12-17 10:19

    HTML--

    css--

    .active{
             background:red;
        }
     button.btn:active{
         background:red;
     }
    

    jQuery--

    jQuery("#my_styles .btn").click(function(){
        jQuery("#my_styles .btn").removeClass('active');
        jQuery(this).toggleClass('active'); 
    

    });

    view the live demo on jsfiddle

提交回复
热议问题