I needs to access the variable outside the function,
Example:
var testData = "LoadedVariable";
function loadFunction(){
testData = "DynamicVariable";
}
alert(testData);
<div onclick="loadFunction();" style="cursor: pointer;">
turn around click
</div>
As per above example, on page load i can access testData as "LoadedVariable". But, when i clicks the button, testData needs to change to "DynamicVariable".
This is for dynamic chat functionality for single web app application.
How to trigger the alert when i clicks button. I know we can alert it inside the function. But i need to achieve the result in above example format.
Thanks in advance.
I added the same in JSFIDDLE