I am working on a website, I have a page containing a list of persons created as follows:
<div class="personsMenu"> <div class="person"> <div class="name">John</div> <div class="age">18</div> </div> <div class="person"> <div class="name">Kate</div> <div class="age">24</div> </div> <div class="person"> <div class="name">Tom</div> <div class="age">17</div> </div> </div>
I also have a text box <input type="Text" id="filterTextBox"/>
Using jquery I need to do the following:
When the user begins to enter text in the text box, divs where the "name" does not contain characters disappears (some kind of dynamic filter, you see only those who call, contains written characters)
So, the logic should be like this:
When a user enters a character in a text field (or deletes it), we scroll through all the "personal" divs and if the "name" div inside this "person" contains the characters that we show, otherwise we will hide it (.show () and .hide () in jquery)
And of course, if the text box is empty, we all show.
Can this be done?
Thanks for any help
source share