function doFirst(){ var button = document.getElementById('button'); button.addEventListener("click",save,false); } function save(){ var FirstName = document.getElementById('FName').value; var LastName = document.getElementById('LName').value; localStorage.setItem(FirstName, LastName); } if(sessionStorage && window.onload === true){ sessionStorage.clear('Fname', 'LName'); } window.addEventListener("load",doFirst,false);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter