문제

If I have something like the following

"use strict";

$(document).ready(function () {

});

I get the warning

'$'is not defined
도움이 되었습니까?

해결책

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

다른 팁

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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top