Frage

If I have something like the following

"use strict";

$(document).ready(function () {

});

I get the warning

'$'is not defined
War es hilfreich?

Lösung

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

Andere Tipps

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>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top