javascript - Detect words and letters typed in input and sort other elements (text in div) with same letters -
I want to input an input, in which you type words or letters to sort any of the elements. For: They have divisions with different words, and when you type something in the input, then type those devices exactly which have the same letter in the input ...
< Code> & lt; Input type = "text" placeholder = "sort ..." & gt; & Lt; Div class = "sortable-items" & gt; & Lt; Div & gt; Dogs & lt; / Div & gt; & Lt; Div & gt; Cats & lt; / Div & gt; & Lt; Div & gt; Dogs & lt; / Div & gt; & Lt; Div & gt; Dogs & lt; / Div & gt; & Lt; Div & gt; Cats & lt; / Div & gt; & Lt; Div & gt; Cats & lt; / Div & gt; & Lt; Div & gt; Dogs & lt; / Div & gt; & Lt; / Div & gt;
If you listen to the funnel event on the input, the function will call you every time If you write or remove a letter, you can then check that the input divs match any value of 'and show / hide it based on it.
$ ('# search'). Key (function () {var searchTerm = $ (This) .val (); $ ("sortable-items div"). Each (function () {if ($ (this) .text (). Match (searchTerm)) {$ (This) .show ();} and {$ (this) .hide ();}});});
You can test this in Bela:
Comments
Post a Comment