6
如果我有類似如下的將jQuery與'use strict'結合使用的正確方法是什麼?
"use strict";
$(document).ready(function() {
});
我得到警告
'$'is not defined
如果我有類似如下的將jQuery與'use strict'結合使用的正確方法是什麼?
"use strict";
$(document).ready(function() {
});
我得到警告
'$'is not defined
(function ($) {
'use strict';
$(document).ready(function() {
console.log('working!')
})
} (jQuery))
你加的jQuery到您的網站?
在tinker.io上嘗試相同的代碼會產生錯誤,但隨後添加jQuery庫並且錯誤消失。
CDN:http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
通過使用這個片段
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
它是由你的問題的標題暗示加,但如果去掉「使用嚴格的」指令代碼是否工作? – nnnnnn 2012-04-21 21:52:01