No special keyword will be required to define variable as Global. Variables declared globally have a global scope, they known throughout the application, from the start of the application.
<!DOCTYPE html>
<html>
<body>
<div id="test"></div>
<script>
//global variable
var a = 100;
globalFunc();
function globalFunc(){
document.getElementById("test").innerHTML = a;
}
</script>
</body>
</html>
Most Helpful This Week
How to check if an element or HTML tag exists using JavaScript?
JavaScript example to change image on click
Using jQuery add new table row on click
How to scroll page to particular Div on click using jQuery?
How can I redirect the user from one page to another using jQuery or pure JavaScript?
Generate random password for form field on click using JavaScript