I am trying to pass a function var into a click event. See the code below.Appreciate.
function coolfunction(){
var cool="hello";
}
$('#good').on('click',function(){
alert(cool);//how can i pass the function var here
});
I am trying to pass a
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div id="good">click</div>
vardeclaration, it assigns the global variable.