0

I am trying to read the enteredValue variable outside the function but the value outside the function remains undefined:

var enteredValue;

$("input").on("keydown",function search(e) {
    if(e.keyCode == 13) {
        alert($(this).val());
        enteredValue = $(this).val().trim().toUpperCase()
        console.log("Code inside: " + enteredValue); //value is read
    }
});

console.log("Code outside : " + enteredValue); //value undefined

Can you please tell me what I'm doing wrong?

fbdg
  • 11
  • 1
  • 7

0 Answers0