To answer your question, there are two ways of declaring a global variable in JavaScript. You can either omit the ‘var’ keyword, or declare the variable outside any function. In this code sample, both thisIsGlobal and thisIsAlsoGlobal are global variables and set to null. var thisIsGlobal= null; function foo() {.. I have big html document with various images with href and src. I want to declare their href and src so as to change only their var values. something like.
3 Steps To Display A Javascript Variable Value In An HTML Page
