0

I can't seem find an solution. I am trying to create exit pop out using modal of Bootstrap but it keeps saying Uncaught Reference Error and won't run my simple jQuery code. Can someone enlighten me?

$(document).ready(function() {
  $("body").mouseleave(function() {
    $("#exitpop-out").show();
  });

  $('.close').click(function() {
    $("#exitpop-out").hide();
  });
});
<div class="modal" id="exitpop-out">
  <div class="modal-dialog">
    <div class="modal-content">

      <!-- Modal Header -->
      <div class="modal-header">
        <h4 class="modal-title">Modal Heading</h4>
        <button type="button" class="close" data-dismiss="modal">&times;</button>
      </div>

      <!-- Modal body -->
      <div class="modal-body">
        <h2>Wait! Don’t Leave Empty Handed…</h2>
        <p>Take the Free Quiz to See How Your Digestive Health Stacks Up!</p>
        <button><a href="">TAKE THE FREE QUIZ</a> </button>
        <p>MAYBE LATER</p>
      </div>
    </div>
  </div>
</div>




<!-- jQuery library -->
<script src="http://code.jquery.com/jquery-3.5.0.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
  • `http://code.jquery.com/` should be `https://code.jquery.com/` – j08691 Apr 23 '20 at 21:09
  • @j08691 Tried but that does not solved it. I took the script src directly at jquery site tho. – Mark Recabo Apr 23 '20 at 21:11
  • 1
    Runs without error when I fix that error in your code. – j08691 Apr 23 '20 at 21:13
  • @MarkRecabo, is the ` – Gustavo Sampaio Apr 23 '20 at 21:26
  • Please include the full text of the error. We're assuming it's "Uncaught Reference Error: $ is not defined", because that's what we see in the snippet, but you have to tell us what it is in your actual code. – Heretic Monkey Apr 23 '20 at 21:28
  • @j08691 Weird. It's not working on me. Even on separate files and folder. – Mark Recabo Apr 23 '20 at 21:30
  • @GustavoSampaio Yes, it is. The first script tag is for modal to simple modal pop out. Beloe one is the src for libraries. – Mark Recabo Apr 23 '20 at 21:32
  • @HereticMonkey Above provided was my actual code. I even did make another separate file and folder. Results still the same. Here's some screenshot to it. https://prnt.sc/s4w3dq – Mark Recabo Apr 23 '20 at 21:41
  • Sigh. So it is "Uncaught Reference Error: $ is not defined"? Or not? From your picture, it appears so, because you're running jQuery code before jQuery has had a chance to load. – Heretic Monkey Apr 23 '20 at 21:43
  • Does this answer your question? [JQuery - $ is not defined](https://stackoverflow.com/questions/2194992/jquery-is-not-defined) – Heretic Monkey Apr 23 '20 at 21:45
  • @HereticMonkey Ok my bad. It says not defined. – Mark Recabo Apr 23 '20 at 21:46

0 Answers0