title: Bootstrap Alert Auto Close
body: <p>My need is to call alert when I click on Add to Wishlist button and should disappear the alert in 2 secs. This is how I tried, but the alert is disappearing instantly as soon as it is appearing. Not sure, where the bug is.. Can anyone help me out?</p>
  
  <p>JS Script</p>
  
  <pre class="lang-js prettyprint-override"><code>$(document).ready (function(){
     $("#success-alert").hide();
     $("#myWish").click(function showAlert() {
        $("#success-alert").alert();
        window.setTimeout(function () { 
           $("#success-alert").alert('close'); 
        }, 2000);             
     });      
  });
  </code></pre>
  
  <p>HTML Code:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div class="product-options"&gt;
     &lt;a id="myWish" href="" class="btn btn-mini"&gt;Add to Wishlist &lt;/a&gt;
     &lt;a href="#" class="btn btn-mini"&gt; Purchase &lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Alert Box:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div class="alert alert-success" id="success-alert"&gt;
     &lt;button type="button" class="close" data-dismiss="alert"&gt;x&lt;/button&gt;
     &lt;strong&gt;Success!&lt;/strong&gt;
     Product have added to your wishlist.
  &lt;/div&gt;
  </code></pre>