Ho can I access and change the value of var from outside the function?
var ArrowFlag = "1";
$('input, textarea, select').focusin( function() {
var ArrowFlag = "0";
//console.log(ArrowFlag) will = 0
});
$(document).bind('keyup', function() {
// When input:focus console.log(ArrowFlag) will = 1
});
When you have input:focus event, var ArrowFlag should have a value of 0.
But, when you have keyUp event after input:focus var ArrowFlag value will be 1. Why? Look like my var ArrowFlag never had it’s value changed.
You have defined two seperate variables called
ArrowFlag, if you want them to be the same variable remove the var from the one inside the focusin callback:Example – http://jsfiddle.net/yyLPE