简体   繁体   中英

Linking javascript file to html

I'm new to javascript and trying to add this http://codepen.io/jklm313/pen/EarFd great map scrolling effect to my site. Css anf HTML read fine, but the js part doesn't want to work. Even if I put the js code in my html. This is the very typical beginning of my html:

<html>
    <head>
        <title>title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width">
        <link rel="stylesheet" href="style.css"/>
        <script src="script.js" type="text/javascript"></script>
    </head>
    <body>

I've searched for clues, but I can't seam to find the issue, is the code outdated or should I add something more? Thanks in advance

Test and make sure you are getting the js file loaded into the page. One method would be to place at the top of the script.js file : alert('loaded');

If you get the alert box then you you have the correct path. If not then you know it is likely a path issue. You may need to make sure your file is in the same directory or else specify the directory in the src

I just glanced at the link and notice it is using the jquery library. Go to jquery.com to learn how to include that js file as well

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