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 Interactive Photo Gallery

Cody Flack
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Cody Flack
Front End Web Development Techdegree Graduate 13,213 Points

Front end Tech-degree Interactive Photo Gallery, Completely lost on how to go about a search plugin.

I don't understand how to make a search plugin search for the title attribute in this project, if somebody could give me a place to start it would very helpful.

Ford Heacock
Ford Heacock
18,068 Points

Hey Cody! Try using an event listener on your search bar to query the "data-sub-html" attribute on each image item. For example:

$("#search").keyup(function(){
      var current_query = $(this).val();
      $('.gallery-item').hide();
      $('.gallery-item').each(function(){
        var current_keyword = $(this).attr("data-sub-html");
        if(current_keyword.indexOf(current_query) >= 0){
       $(this).show();
        }

Obviously replace with your id and class names. Hope this helps!

1 Answer

hi there I have been trying to get this to work and can seem to make it function. keeps coming back with a syntaxerror