"enter" event listener problem/wikipedia API

Hello guys. I made a function so it listens to “enter” key to submit a search.However it works but it doesn’t. If i type something into the box and press enter it doesn’t work,but if i press the button,it works,then i type another word and press enter it works as many times as i want. Any ideea why is that?
Here’s my CodePen
https://codepen.io/GummyGod/full/PEaJgL/

You need to look at where you’ve placed your event handler for the text input. It is inside the callback for the search submit, so it doesn’t get set up until after the first search. I would move it down, as the last thing before closing the $(document).ready section.

2 Likes

Oh right. Thanks. It worked after putting it outside the callback