Skip to content
Advertisement

JQuery Search function for div containers

I am trying to use JQuery and this script (to filter my mySql output):

JavaScript

the mySql entries I want to filter look like this in html:

JavaScript

so each <div class="card" id="notes"> is one entry.

The problem is (as you can see) I probally use this function wrong because I filter $("#notes div").filter(function() {

so if I search “ABC” the script only display the div container which is containing the “Title ABC”. same goes if I search “XYZ” etc.

So what I want is. Whatever I search for it shouls display the whole div container <div class="card" id="notes"> where the search entry is found in either title, text or date.

would someone be so kind to explain me how I can make it working? I am thankfull for every tipp or even a link to a good tutorial I can work with.

thanks in advance and best greetings.

Advertisement

Answer

#notes is only targetting 1 .card. "#notes div" then filters divs within it. If you want to filter .card‘s by their text content, you should find all .cards by searching on their parent like this:

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement