i want to get a variable (which is set when a link is clicked) over to a function and show it as a pop out.
the code as shown below:
$('a#link1').click(function(e){
e.preventDefault();
var value = 'true';
});
function exe(){
alert(value);
}
when the function is executed , all i get is value is undentified.
So anyone knows a way around it?
Variables have scope, you define the
valuevariable in the scope of the onclick closure, and it wont be accessible outside it.The following would work:
However having many global variables will make your project hard to maintain, and there are other more clean solutions available. In general i’d recommend you to read a proper book on programming though 🙂