(function(){
$("#btn1").on("click",function(){
var myval = 123;
console.log(myval);
});
$("#btn2").on("click",function(){
console.log(myval);
});
})();
How to get the value of myval on #btn2 event. (Getting error Uncaught ReferenceError: myval is not defined)