-1

The script does not work, and the ebugging screen shows the error

$ is not defined

<script href="https://code.jquery.com/jquery-3.3.1.min.js"></script>

<script type="text/javascript">
    $(window).on('scroll', function(){
        if($(window).scrollTop()){
            $('nav').addClass('black');
        }else{
            $('nav').removeClass('black');
        }
    })
1
  • 8
    A <script> tag should have a "src" attribute, not "href", to load an external script. Commented Feb 25, 2018 at 15:29

1 Answer 1

2

This line:

<script href="https://code.jquery.com/jquery-3.3.1.min.js"></script>

You must edit "href" to "src"

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

2 Comments

Glad to help. You are newbie of html?
Yes, i am! Can you help me with another jquery question?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.