2017-02-25 66 views
0

我有一個按鈕,其中:hover:focus css屬性。在盤旋時,顏色變爲紅色。 現在,當我點擊它時,出現一個Alertify確認框,然後我按ok或取消顏色更改爲紅色,因爲:focus屬性。 如何取消綁定: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」)。blur();像這樣:

$(".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>

相關問題