I have a HTML page where I want one button to increase the font size and the same button to decrease the font size when clicked.
I am using jQuery like so:
$("p").css("font-size","20")
However, when I do that the font size increases for maybe 2 seconds and then goes back to normal. It appears that the page is refreshing after I click the button… Why is that?
You have to return false [prevent the default action] so that the page won’t be posted back.
Also my suggestion would be to use two different css classes for this and toggle those classes using
toggleClass( class )