DEV Community

loading...

Discussion on: Problem with localStorage

Collapse
andybullet profile image
AndyBullet Author

Is there a way to make it work on a single click?

Collapse
webdevchallenges profile image
Marc

Yes:

function changeAndStoreText() {
  textElement.innerHTML = 'Another text';
  var textContent = textElement.textContent;
  localStorage.setItem('firstScreenText', textContent);
}