<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$('div'); // <--- THIS DOESN'T WORK
</script>
我在上面的代码中遇到错误。在检查 .js 代码时,我找不到名为 $
的函数,但根据文档,应该有一个。
最佳答案
试试 http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
。注意开头的 http:
。
尽管它 should work without that as well .我猜您正试图通过 file://
在本地(而不是通过 HTTP 在服务器上)打开 HTML。在那种情况下,当然是无方案的 URL won't work .
关于javascript - $ 函数不工作(丢失?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10156478/