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

Robert Weber
Front End Web Development Techdegree Student 10,340 PointsFiltering search bar for javascript project
Hi guys, I have posted a few questions lately for help on my project. I have been messing around with the javascript coding and still have yet to find a solution to my problem. I need the search bar to filter through the images on the page based off the keywords in the captions. It is supposed to only show images that contain the keywords typed in the search bar, and hide the remaining photos that do not contain the keywords. Here is some of my code...
<form action="" method="post">
<fieldset>
<input type="search" id="filter" name="user_search" placeholder="Search(16pt)">
</fieldset>
</form>
<ul class="imageGallery">
<li><a href="img/fullsize/01.jpg" data-title="I love hay bales. Took this snap on a drive through the countryside past straw fields." data-lightbox="picture_one"><img src="img/thumb/01.jpg" alt=""></a></li>
</ul>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="js/lightbox.js" type="text/javascript"></script>
<script src="js/main.js" type="text/javascript"></script>
</body>
</html>
$("#filter").keyup(function(search){
var $captions = document.querySelectorAll(".imageGallery a");
var $image = ".imageGallery a";
if ( search.toLowerCase() === $captions.toLowerCase() ) {
$image.show();
} else {
$image.hide();
}
});