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

Buttons won't show selected class when clicked

I apologize in advance. I don't know how to properly post my code formatted. So, as the subject says, my buttons won't display a class of selected when clicked. To me, my code looks identical to Dave's. Please help me figure out what I'm missing. Thanks.

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>AJAX Flickr Photo Feeder</title>

<link href='http://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet'

type='text/css'>

<link rel="stylesheet" href="css/main.css">

<script>"http://code.jquery.com/jquery-1.11.0.min.js"</script>

<script src="js/flickr.js"></script>

</head>

<body>

<div class="grid-container centered">

<div class="grid-100">

  <div class="contained">

    <div class="grid-100">

      <div class="heading">

        <h1>Flickr Photo Feeder</h1>

        <p>Choose which kind of animal you'd like to return photos of...</p>

      </div>

      <ul class="filter-select">

        <li><button>Dog</button></li>

        <li><button>Cat</button></li>

        <li><button>Moose</button></li>

      </ul>

</div>

    <div id="photos">



    </div>

  </div>

</div>

</div>

</body>

</html>

JavaScript

$(document).ready(function () {

$('button').click(function() {

$(this).addClass('selected');

});

});

Ben Schroeder
Ben Schroeder
22,818 Points

Do you get any errors in the console?

1 Answer

Ben Schroeder
Ben Schroeder
22,818 Points

This...

<script>"http://code.jquery.com/jquery-1.11.0.min.js"</script>

... should be this:

<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>

Shoot.... totally missed that. Sorry about that. Thanks.