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

javascript - how to HTML link to external js file - Stack Overflow

programmeradmin4浏览0评论

I am trying to simply copy and paste the code from this link, but it seems that the javascript file is not being picked up. The HTML and CSS are working just fine, but I can't seem to link the javascript file. I am not sure why, any help would be appreciated.

Also here is the code linking my js file to the HTML.

<script style="text/javascript" src=".2.4.min.js"></script>

<script type="text/javascript" src="script.js"></script>

I am trying to simply copy and paste the code from this link, but it seems that the javascript file is not being picked up. The HTML and CSS are working just fine, but I can't seem to link the javascript file. I am not sure why, any help would be appreciated.

Also here is the code linking my js file to the HTML.

<script style="text/javascript" src="https://code.jquery./jquery-2.2.4.min.js"></script>

<script type="text/javascript" src="script.js"></script>
Share Improve this question asked Oct 4, 2016 at 20:29 FredTheHomieFredTheHomie 411 gold badge2 silver badges8 bronze badges 5
  • Have you made sure the paths are correct? Any console errors? – Andrew Li Commented Oct 4, 2016 at 20:30
  • We'll need to know a little more to help. Open console <F12>, copy errors, paste here... – War10ck Commented Oct 4, 2016 at 20:34
  • jquery has to be included before (above) any other javascript. if you place it after you will get stuff is undefined errors.. – Robert Parham Commented Oct 4, 2016 at 20:34
  • Sidenote: style is an attribute to write inline css, and type is not required as per html5 standard. – Domino Commented Oct 4, 2016 at 20:35
  • side-sidentoe: type: is not required either, so that's probably not the problemm – Robert Parham Commented Oct 4, 2016 at 20:36
Add a ment  | 

3 Answers 3

Reset to default 4

This:

<script style="text/javascript" src="https://code.jquery./jquery-2.2.4.min.js"></script>

Should be:

<script type="text/javascript" src="https://code.jquery./jquery-2.2.4.min.js"></script>

Change style to type.

Should the top line say "type=" and not "style="?

As can see, the script links very well as I have tested it. However, please change [the attribute is type not style]

<script style="text/javascript" src="https://code.jquery./jquery-2.2.4.min.js"></script>

to

<script type="text/javascript" src="https://code.jquery./jquery-2.2.4.min.js"></script>
发布评论

评论列表(0)

  1. 暂无评论