title: Uncaught TypeError: Object [object Window] has no method 'each'
body: <p>I'm creating a jQuery plugin that interacts with Bootstrap, and I get the following error when I call the function on a jQuery element:</p>
  
  <pre><code>Uncaught TypeError: Object [object Window] has no method 'each' 
  </code></pre>
  
  <p>This is the JavaScript in question:</p>
  
  <pre><code>!function ($) {
  $.fn.alertAutoClose = function (interval) {
    setTimeout(function () {
      return $(this).each(function () {
        $(this).hide();
      });
    }, interval);
  }(window.jQuery);
  </code></pre>
  
  <p>This is how the plugin is triggered:</p>
  
  <pre><code>$(".alert").alertAutoClose(1000);
  </code></pre>
  
  <p>This is the HTML on the page:</p>
  
  <pre><code>&lt;div class="alert fade in"&gt;
    &lt;button type="button" class="close" data-dismiss="alert"&gt;&amp;times;&lt;/button&gt;
    &lt;strong&gt;Warning!&lt;/strong&gt; Best check yo self, you're not looking too good.
  &lt;/div&gt;
  </code></pre>