I have a text input and I want to alert the input.value after press enter
so I have made this code HTML :
<input type="text" id="food">
js :
$('#food').on('keypress',function(e) {
if(e.which == 13) {
const food = $('#food').value;
alert(food);
}
});
in the alert, it's showing undefined.
in addition, there is no console error in the console