简体   繁体   中英

Javascript page not linking to my HTML File

I was originally just using JSFiddle, but I wanted to move my project over to Notepad++ so I could have the files on my computer. The problem is, my Javascript on my page is not going into effect.

Heading Code:

<head>
<link href="C:/HTML/App/app.css" type="text/css" rel="stylesheet" />
<script type='text/javascript' src='C:/HTML/App/app.js'></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
</head>

Any reason why? It links to my style sheet just fine, but my app.js does not seem to be working.

Three things:

app.js uses jQuery so the jQuery file needs to be included first

Also, you said you're running this on your PC. You could be using localhost, but if you're running from file:// , src=" // ... won't work because your browser will be looking for file: //ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js instead of http: //ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js
so all you need to do is add the http:

But did you mean jQuery not jQuery UI? (Thanks @ahren)

<head>
    <link href="C:/HTML/App/app.css" type="text/css" rel="stylesheet" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <!-- <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script> -->
    <script type='text/javascript' src='C:/HTML/App/app.js'></script>
</head>

Jquery comes first, like so:

<head>
    <link href="C:/HTML/App/app.css" type="text/css" rel="stylesheet" />
    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
    <script type='text/javascript' src='C:/HTML/App/app.js'></script>
</head>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM