2017-02-25 2 views
0

:hover:focusのCSSプロパティを持つボタンがあります。ホバリングしている間、色は赤に変わります。 これをクリックするとAlertifyの確認ボックスが表示され、次にok3800を押すか、:focusプロパティのために赤色の色の変更がキャンセルされます。 okをクリックするか、キャンセルすると、どうすれば:focusをバインド解除できますか?"altertify"の確認モーダルを閉じた後、ボタンからフォーカスを削除するにはどうすればいいですか?

<html> 
<head> 
    <script src="https://cdn.jsdelivr.net/alertifyjs/1.8.0/alertify.min.js"></script> 
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/alertifyjs/1.8.0/css/alertify.min.css"/> 
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/alertifyjs/1.8.0/css/themes/default.min.css"/> 

</head> 

<style> 
.btn-test:hover,.btn-test:focus{ 
background-color:red; 
} 
</style> 

<body> 


<button class="btn-test">Click Me</button> 


</body> 

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 

<script> 
$(".btn-test").click(function(){ 

alertify.confirm('Confirmation', 'You clicked', function() { 
       //do nothing 
      } 
      , function() { 
       //do nothing 
      }); 

}); 
</script> 

</html> 

答えて

1

このコードをjsファイル$( ".btn-test")に追加するだけで済みます。このような:

$(".btn-test").click(function(){ 
 

 
     $(".btn-test").blur();   
 
    
 

 
alertify.confirm('Confirmation', 'You clicked', function() { 
 
       //do nothing 
 
      } 
 
      , function() { 
 
       //do nothing 
 
      }); 
 

 
});
.btn-test:hover,.btn-test:focus{ 
 
background-color:red; 
 
}
<html> 
 
<head> 
 
    <script src="https://cdn.jsdelivr.net/alertifyjs/1.8.0/alertify.min.js"></script> 
 
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/alertifyjs/1.8.0/css/alertify.min.css"/> 
 
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/alertifyjs/1.8.0/css/themes/default.min.css"/> 
 

 
</head> 
 

 
<body> 
 

 

 
<button class="btn-test">Click Me</button> 
 

 

 
</body> 
 

 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 

 
</html>

関連する問題