I’ve a small question.
What I want to do is make a InnerHTML variable.
Maybe code explains it better, what I have now:
—–Javascript—–
var VarOne = 'Four';
var VarTwo = 'Five';
var VarThree = 'Six';
function MyFunction(){
document.getElementById("MyDiv").innerHTML = ['Var' + event.target.id];
}
—–Html—–
<div id="MyDiv"></div>
Instead of looking for a var, it gives as outcome ‘VarOne, VarTwo, or VarThree, very logically, but how can I make it so he uses the var?
Instead of using a string as a variable name directly, put your values into a hash: