title: Trying to prevent default
body: <p>This is a project I am working on, a little popup ad for my client's website that will tell users about their summer camps coming up. I just want the ad to show up on load, and then the user can choose to close the ad or click the link to go to the registration page.</p>
  
  <p>I am trying to get this code to work but my problem is that when I click one of the close buttons the ad closes, then the page reloads and the ad is right back where it was. I am trying to figure out where to appropriately place my "prevent default" code but it either works before the ad can even show up the first time, or in the case shown here... not at all.</p>
  
  <p>I realize that I am using both jQuery and JS but I am very new to this and I am piecing together code as I find it.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(".close").click(function(){
  $("#summercampad").addClass("hidden");
  onload.preventDefault();
  
  });
  
  window.onload = function () {
  document.getElementById("summercampad").className =
  document.getElementById("summercampad").className.replace
    ( /(?:^|\s)hidden(?!\S)/g , '' )
  };
  
  &lt;/script&gt;
  &lt;div id="summercampad" class="hidden" &gt;
  &lt;div id="popupcontainer"&gt;
      &lt;div id="closepopup"&gt;
          &lt;a href="#" class="close"&gt;&lt;img src="https://cdn6.bigcommerce.com/s-p98jqjm/product_images/uploaded_images/closebtn.png?t=1429039040" alt="close"/&gt;     &lt;/a&gt;
      &lt;/div&gt;
      &lt;div id="pic"&gt;
          &lt;img src="https://cdn6.bigcommerce.com/s-p98jqjm/product_images/uploaded_images/popuppic.jpg?t=1429038436" alt="basketball"/&gt;
      &lt;/div&gt;
      &lt;div id="popuptext"&gt;
          2015 SUMMER CAMPS&lt;br&gt; 
          BOYS &amp;amp; GIRLS • ANY SKILL LEVEL&lt;br&gt;
          &lt;span&gt;SPACE LIMITED - SIGN UP NOW!&lt;/span&gt;
      &lt;/div&gt;
      &lt;div id="registerbtn" &gt;
          &lt;a href="/camp-registration/"&gt;
          &lt;img src="https://cdn6.bigcommerce.com/s-p98jqjm/product_images/uploaded_images/registerbtn.png?t=1429039883"/&gt;
          &lt;/a&gt;
      &lt;/div&gt;
      &lt;div id="nobtn"&gt;
          &lt;a href="#" class="close"&gt;
          &lt;img src="https://cdn6.bigcommerce.com/s-p98jqjm/product_images/uploaded_images/nothanksbtn.png?t=1429039884"/&gt;
          &lt;/a&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>