Как я могу отобразить кнопку в двух разных цветах при нажатии на кнопку

Заменить URL-адреса в тексте ссылками HTML, игнорировать URL-адреса в теге href / pre. https://github.com/JimLiu/auto-link

0
задан test user 18 January 2019 в 08:22
поделиться

2 ответа

 var myButton = $('#btn');
            myButton.click(function () {
                if ($(this).hasClass('inActive')) {
                    $(this).removeClass('inActive').addClass('active');
                    $(this).css('color', 'blue');
                } else {
                    $(this).removeClass('active').addClass('inActive');
                    $(this).css('color', 'white');
                }
            });
#btn{
color:white;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button class='inActive' id='btn'>Click here</button>

0
ответ дан David Söderberg 18 January 2019 в 08:22
поделиться
$(document).ready(function(){
  $("#btn1").click(function(){
    if($(this).hasClass('buttonActive')){
       $(this).removeClass("buttonActive").addClass("buttonInactive");
       $('#idsToDisable').prop('disable', true);
     }else if($(this).hasClass('buttonInactive')){
       $(this).removeClass("buttonInactive").addClass("buttonActive");
       $('#idsToDisable').prop('disable', false);
     }
  });
});

Отредактировано в соответствии с комментарием

0
ответ дан Sanjit Bhardwaj 18 January 2019 в 08:22
поделиться
Другие вопросы по тегам:

Похожие вопросы: