Garmaine Staff asked 1 year ago

I know there are similar problems as one I am having, but I tried different solutions (at least I think) and nothing is working. So I wrote JQuery code in JS file but when I put path for js and jq version in HTML file it just isn't working in either of my web browsers, but when I put JQuery code direct in HTML it is working. I checked code many times,searched for typing mistakes but didn't find anything. Maybe I didn't see something obvious so please tell me. This is my first time with this so…Thank you

$(document).ready(function() {
  $(".collapse-control").click(function() {
    $(".collapse-box").slideUp();
    $(this).closest(".collapse").find(".collapse-box").slideDown();
  });
});
<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">

  <title>Lesson</title>

  <meta name="viewport" content="width=vice-width, initial-scale=1">
  <meta name="author" content="Unknown">
  <meta name="description" content="description">
  <meta name="keywords" content="web,html,css,html5,development">

  <script src="js/script.js"></script>
  <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

</head>


<body>

  <div class="collapse">

    <h2 class="collapse-control">Open box 1</h2>

    <div class="collapse-box">
      This is box 1
    </div>

  </div>

</body>

</html>