I'm at very beggining stage and I'd like to know something.. Is there a way to set a variable like this (or a similiar way)?
<body>
<button id="button1" onclick="change(this.something);"> click me </button>
<button id="button2" onclick="change(this.lorem);"> or this one </button>
<div id="target"> change this content </div>
<script>
function change(variable)
{
document.getElementById("target").innerHTML = variable;
}
</script>
</body>
or something like this
<body>
<button id="button1" onclick="change(this.value(v1));"> click me </button>
<button id="button2" onclick="change(this.value(v2));"> or this one</button>
<div id="target"> change this content </div>
<script>
function change(value)
{
var v1 = "something";
var v2 = "lorem";
document.getElementById("target").innerHTML = variable;
}
</script>
of course both are not working.. just don't know how to find an answer.