-2

I'm new to JavaScript and trying to add this http://codepen.io/jklm313/pen/EarFd great map scrolling effect to my site. CSS and 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?

1
  • 1
    This question is similar to: How do I link a JavaScript file to a HTML file?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Oct 21, 2024 at 14:53

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

-1

You have used 'jquery/2.1.3' in your codepen.

And the code you have shared does not include that.

You need to update your head section with adding jquery.

<head>
        <title>title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width">
        <link rel="stylesheet" href="style.css"/>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js" type="text/javascript"></script>
    </head>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.