I'm encountering a strange issue in the fiddle linked above. When typing a character into an input followed by pressing the down key, the console logs two values: one correct value of 3
, and one incorrect value of 0
.
The challenge is to select the element following a specific input:
// this works...
console.log($('.autocomplete li').length);
// this does not work
console.log($(this).next('.autocomplete li').length);
Even though logging $(this)
returns input
as expected, I have experimented with methods like .nextAll
and .find
without success.
What could be causing it to fail finding the .next
element of the target?