How to maintain a JS function after refresh?

Asked

Viewed 283 times

0

I’m trying to implement this function:

function aumentarFont() {
document.getElementById("myP").style.fontSize = "medium";
}

Executes the action:

<a href="#" type="text" onclick="aumentarFont()">A+</a>

Apparently it is working correctly, but when I refresh the page the font returns to its normal size. How do I keep this function running after refresh?

  • 3

    You will have to save the size of this font somewhere (in the server - database, or in the client - localStorage, etc.) and work in a way of "set" this setting every time you load the page.

  • how about using Session

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.