Assuming I have a div structure with a text box:
<input id="filter" type="text" name="fname" /><br /> <input type="text"> <div id="listofstuff"> <div class="anitem"> <span class="item name"Dog</span> <span class="itemdescruption">AboutItem1</span> </div> <div class="anitem"> <span class="item name">Doodle Bird</span> <span class="itemdescruption">AboutItem2</span> </div> <div class="anitem"> <span class="item name">Cat</span> <span class="itemdescruption">AboutItem3</span> </div> </div>
I want to make it initially .. to say that it shows 3 anitems , I want to make it so that if the user has a character entered in the search field, he will only show divs that correspond to the record that the user enters.
Ex. Therefore, if the user types βDβ, he will hide all other divs without βDβ in the βelement nameβ. If the user types another letter βogβ, then the only div to be displayed is the div with the βelement nameβ βDogβ. If the user deletes the delete key to delete βgβ, then two divs βDogβ and β Doodle Bird. " If the user deletes everything that they typed in the text box, then all the elements will appear.
How to do it, if possible? I think I may have to use .live (), but I'm really not sure.
source share