Rahul Shah
Rahul Shah

Reputation: 1407

How to put a .js file in html

The question seeems pretty simple.The usual method is simply using this code

<script src='https://code.angularjs.org/1.0.0rc9/angular-1.0.0rc9.js' type='text/javascript'/>

Alternatively, in Jsfiddle, we use the "External resources tab"


(source: ctrlv.in)

I have issues in implementing a particular code in my website. After much troubleshooting, I found out that, if I use this code to put a .js file:

 <script src='file link here' type='text/javascript'/>

the code doesn't work. If I use the external resources option in jsfiddle, it works. If I manually put it, it doesn't

Working fiddle: http://jsfiddle.net/U7Bz9/1972/ Unworking fiddle : http://jsfiddle.net/U7Bz9/1973/

I am shocked as to how this is possible.

Upvotes: 0

Views: 103

Answers (1)

Quentin
Quentin

Reputation: 943686

The end tag for script elements is mandatory.

<script 
    src='https://code.angularjs.org/1.0.0rc9/angular-1.0.0rc9.js' 
    type='text/javascript'>
</script>

Upvotes: 5

Related Questions