Domanda

If I have something like the following

"use strict";

$(document).ready(function () {

});

I get the warning

'$'is not defined
È stato utile?

Soluzione

( function ( $ ) {
    'use strict';
    $( document ).ready( function () {
        console.log( 'working!' )
    })
} ( jQuery ) )

Altri suggerimenti

Did you add jQuery to your site?

Trying the same code on tinker.io produces the error, but then add the jQuery lib and the error goes away.

CDN: http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js

add it by using this snippet

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top