2016-02-20 179 views

回答

0

試試這個代碼,它會告訴你如何顯示一個sweetalert。你只需要用你的表單來做到這一點。

<head> 
 
    <script src="dist/sweetalert.min.js"></script> 
 
    <link rel="stylesheet" type="text/css" href="dist/sweetalert.css"> 
 
</head> 
 
<body> 
 
    <div class="showcase sweet"> 
 
    <h4>Sweet Alert</h4> 
 
    <button>Show error message</button> 
 
     
 
    <h5>Code:</h5> 
 
    \t <pre> 
 
      <span class="attr">sweetAlert</span>(<span class="str">"Oops..."</span>, 
 
      <span class="str">"Something went wrong!"</span>, 
 
      <span class="str">"error"</span>); 
 
     </pre> 
 
    </div> 
 
</body> 
 

 
<script> 
 
    document.querySelector('.showcase.sweet button').onclick = function(){ 
 
\t swal("Oops...", "Something went wrong!", "error"); 
 
    }; 
 
</script>