M. Gar M. Gar - 5 months ago 5
jQuery Question

Filter for specific content in a class

I have been learning about filter and show content in my page, right now I add a

element to make the search so I based the function of the select element in my function from the text input and Works fine, check the Jsfiddle but if I want to use the select to filter just the part of
Category: something
that is this part of the code
<span class="pull-right category">
How can I do it?.

Right now if I choose the option
in the dropdownlist shows me the first and third panel because in the third
content exist the word First so I want to point just to the content of the class
from my span element and show the panels with
as category not in any other part of the panel.

EDIT: Basically I need to filter with the dropdowlinst by select the category and shows only the panel with the category I choose no matter the other content of the panel, just the


In your filter, look for the term only within the span with the class category rather then the entire text of the panel.


$(this).text().toLowerCase().indexOf(term.toLowerCase()) > -1


$(this).find('span.category').text().toLowerCase().indexOf(term.toLowerCase()) > -1