I've tried looking through previously asked questions, but they all seem to be a bit too complicated for my level, or using jquery which I haven't learned yet and do not understand.
Here's what I want to do:
I have this html:
<p id="demo">Javascript Test</p>
<button type="button" onclick="fontFunction()">Click Me!</button>
<script src="scripts/lightbulb.js"></script>
and I have this JS linked:
function fontFunction() {
if (document.getElementById("demo").style.fontSize = "16px") {
document.getElementById("demo").style.fontSize="32px";
} else {
document.getElementById("demo").style.fontSize="16px"
}
}
All I want to do, is click the button, and it changes the font size to 32px (which WORKS!), and then click it again, and have the font size change BACK to 16px (THIS DOES NOT WORK).
I thought making a JS script that checks the fontsize, and changes it based on if the font size is 16 (in which case it makes it 32, but if it's not 16 it will make it 16) would work.
My apologies, I am BRAND NEW to javascript, so if at all possible please direct me to a place that can explain how to do this as if i were 5 years old (or explain it in such a manner).
Thank you so much!