0

我有这个简单的脚本:

$(document).ready(function() {
    alert("HI");
)};

警报从来没有出现过。但是如果我删除 document.ready 部分,它将立即加载。有谁知道为什么?

4

3 回答 3

5

你有一个错字。最后一行应该});不是)};

于 2013-08-15T23:24:28.220 回答
3

Yes. Variables starting with $ signify (generally since other libraries could use $ sign too) jQuery objects. So its most likely your jQuery object is not loaded.

When you remove the $(document).ready ..) it becomes just plain javascript and you get the alert("hi").

ALSO there is this typo in the last line )}; should be }); which only means your jQuery variable of $(document) was not set properly.

于 2013-08-15T23:22:32.227 回答
2

最后一行应该是

 })

代替

 )}
于 2013-08-15T23:24:47.203 回答