Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AJAX Basics (retiring) jQuery and AJAX Introducing jQuery

Ben Ahlander
Ben Ahlander
7,528 Points

why is the button not hiding?

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>AJAX with JavaScript</title>
  <link href='http://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
  <link rel="stylesheet" href="css/main.css">
  <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>


  <script>

  function sendAJAX() {
    $('#ajax').load('sidebar.html');
    $('#ajax').hide();

  }

  </script>
</head>
<body>
  <div class="grid-container centered">
    <div class="grid-100">
      <div class="contained">
        <div class="grid-100">
          <div class="heading">
            <h1>Bring on the AJAX</h1>
          </div>
          <button id="load" onclick="sendAJAX()" class="button">Bring it!</button>
          <div id="ajax">

          </div>
        </div>
      </div>
    </div>
  </div>
</body>
</html>

3 Answers

Arien Woodrow
Arien Woodrow
7,222 Points

The button's id is load not ajax so $('#load').hide();

ywang04
ywang04
6,762 Points

The id of button is "load" instead of "ajax".

 $('#ajax').hide();  //change it to "load"

 $('#load').hide();

try to put it in a click function like this $( "ajax" ).click(function() { $( this ).hide(); });

Hope this helps : )