jquery
$(selector).on('click',function(){
var $myvar = 'hi';
});
alert($myvar); // this won't alert hi as this is out of click function
How can I call that $myvar outside the function?
Update
I tried with below answers but seems not working http://jsfiddle.net/G5vAv/1/
I would like to return the value 'hi' when alerting. Any idea?