1
In a certain method, from my input, when typing "me" it checks if the fruit exists in this array:
['banana', 'melao', 'uva', 'melancia']
In case, brings me (position 1 - melao and position 3 - watermelon).
I tried using the inArray
, but it just observes the full word and not just part of the string of it...
PS: I cannot use jquery UI
for technical reasons, as it would conflict with the function autocomplete
.
I’m not sure what you’re looking for, so if you could clear up the question, that would be great. But in general you can do something like
arr.filter(el => { return el.indexOf(letras) != -1; });
. If you explain better what you want to do I can give an example.– Sergio
Take a look at the fiddle and tell me if it helps you, is an example without the use of jQuery. Had posted an answer but removed because I do not know if I understood your question hehe :)
– Brunno
Did not understand the question, how so inArray only returns the whole word? inArray returns the position of the item in the array and not the word. Clearly that using the position of the index returned in the array will return for example
"uva"
. After all you want to return a fruit or you want to divide the words in each item of the array, put as you did to understand the problem.– Guilherme Nascimento
Wow, thanks for the answers. , I want to write b and already appear banana, inarray only thinks if I write the full word. @Brunno era isso ae! I only needed a few adjustments. Valeu!
– caiocafardo
@Good caiocafardo who helped you, blurs the exclusion of the answer :)
– Brunno
There’s a way to get the job done so we can help you?
– Ivan Ferrer