最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - $ or jQuery is undefined - Stack Overflow

programmeradmin3浏览0评论
<script href=".10.2.min.js"></script>

<script>
    console.log($);
    console.log(jQuery);
</script>

I get a message that $ or jQuery is undefined: what’s wrong?

It’s just an empty index.html, with no other code.

<script href="http://code.jquery./jquery-1.10.2.min.js"></script>

<script>
    console.log($);
    console.log(jQuery);
</script>

I get a message that $ or jQuery is undefined: what’s wrong?

It’s just an empty index.html, with no other code.

Share Improve this question edited Jun 23, 2014 at 18:21 Guja1501 1,0288 silver badges16 bronze badges asked Jan 21, 2014 at 20:40 yeah its meyeah its me 1,1414 gold badges20 silver badges29 bronze badges 6
  • If you want a hosted version of jQuery you might want to use a CDN version. – tadman Commented Jan 21, 2014 at 20:42
  • @tadman use googles url for it. – Shawn Commented Jan 21, 2014 at 20:43
  • 2 @tadman That IS a CDN version. MaxCDN – Kevin B Commented Jan 21, 2014 at 20:43
  • @KevinB Right you are. I thought that was the download link pasted in there. – tadman Commented Jan 21, 2014 at 20:43
  • And, by using MaxCDN, it won't be blocked by panies (or countries) that block google-related traffic. – Kevin B Commented Jan 21, 2014 at 20:45
 |  Show 1 more ment

3 Answers 3

Reset to default 25

You used the href attribute to include the script to the file.

href is an invalid attribute for <script></script> tags. Use src instead...

<script src="http://code.jquery./jquery-1.10.2.min.js"></script>

You have an error in your declaration. You should use

<script src="...">

instead of

<script href="">.
<script src="http://code.jquery./jquery-1.10.2.min.js"></script>

<script>
    console.log($);
    console.log(jQuery);
</script>

Always try to use js files on your local machine.

发布评论

评论列表(0)

  1. 暂无评论