How to Use jQuery in Grails 3.0
<p>I am trying to figure out how to get jQuery running in my Grails 3.0 application. I attempted adding the jQuery dependency like so in my build.gradle</p>

<pre><code>runtime "org.grails.plugins:jquery:1.11.1"
</code></pre>

<p>When I did that, the application failed to build. I have not changed anything in my application.js file, so it still looks like this:</p>

<pre><code>//= require jquery-2.2.0.min
//= require bootstrap
//= require_tree .
//= require_self

if (typeof jQuery !== 'undefined') {
    (function($) {
        $('#spinner').ajaxStart(function() {
            $(this).fadeIn();
        }).ajaxStop(function() {
            $(this).fadeOut();
        });
    })(jQuery);
}
</code></pre>

<p>Inside of my gsp pages I have tried both:</p>

<pre><code>&lt;g:javascript&gt;
          $( document ).ready(function() {

                $( "#a" ).click(function( event ) {

                     alert( "Thanks for visiting!" );

                 });

           });
&lt;/g:javascript&gt;
</code></pre>

<p>and</p>

<pre><code>&lt;g:javascript library='jquery'&gt;
            (function($){
                $( document ).ready(function() {

                    $( "#a" ).click(function( event ) {

                        alert( "Thanks for visiting!" );

                    });

                });
            })(jQuery);
&lt;/g:javascript&gt;
</code></pre>

<p>The first resulted in an error stating that '$' was not defined and the second said that jQuery was not defined. So how am I supposed to run jQuery inside of a gsp page?</p>