I have 4 divs, and depending on what the user clicks I want to set a variable on each of them, which I then want to save using sessionStorage.
<div id="1" onClick="sessionStorage.id=1">Select Me as 1</div>
<div id="2" onClick="sessionStorage.id=2">Select Me as 2</div>
<div id="3" onClick="sessionStorage.id=3">Select Me as 3</div>
<div id="4" onClick="sessionStorage.id=4">Select Me as 4</div>
Then on the <head></head>
area I've added:
sessionStorage.setItem("id", "");
sessionStorage.getItem("id");
alert(id);
My problem is that the values are not changing and the onclick
doesn't see to be storing the new values.
How can I do this right?