Using the $ Alias Without Creating Global Conflicts
<p>For learning jQuery i am going through the book "Jquery: CookBook". In this book i gone through the concept of using $ alias of 'jQuery' without creating Global Conflict. As per the book the syntax is as follows: </p>

<pre><code>  &lt;html&gt;
  &lt;head&gt; 
   &lt;script type="text/javascript" src="jquery-min.js"&gt;
   &lt;/script&gt;
   &lt;/head&gt;
   &lt;body&gt;
   &lt;script&gt;
   (function($){         //function to create private scope with $ parameter
        alert("Hello");    //private scope and using $ without worry of conflict
    })(jQuery); 
   &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;      
</code></pre>

<p>But the above code is not working and firebug shows syntax error. I am not able to find any document based on above concept. can anyone please tell me that how to use the above syntax correctly.Thanks in advance. i know the above syntax looks weird. But the book says:</p>

<p>All jQuery code could be encapsulated inside the following self-invoking
function:</p>

<pre><code>(function($){ //function to create private scope with $ parameter
//private scope and using $ without worry of conflict
})(jQuery); //invoke nameless function and pass it the jQuery object
</code></pre>
