I'm confused on what I'm doing wrong here I'm following a tutorial and it works fine for them but not me. I've switched around many things to try to find the problem but it just doesn't seem to work.
HTML
<h1 class="settingOne" id="mainText">Simple HTML Page</h1>
<p class="center">
This is a very simple HTML page.
</p>
<p class="center">It's about as basic as they come. It has: </p>
<ul class="center">
<li>An H1 Tag</li>
<li>Two paragraphs</li>
<li>An unordered list</li>
</ul>
<button id="changeButton">
<p>
Hey push this to change the header thing
</p>
</button>
CSS
.settingOne {
font-family: fantasy;
color: blue;
text-align: center;
}
.settingTwo {
font-family: serif;
color: red;
text-align: center;
}
JAVASCRIPT
function changeClass() {
document.getElementById("changeButton").onclick = function () {
if (document.getElementById("mainText").className === "settingOne") {
document.getElementById("mainText").className = "settingTwo";
} else {
document.getElementById("mainText").className === "settingOne";
}
};
}
window.onload = function () {
preparePage();
}
;
document.getElementById("mainText").className === "settingOne";you should assign value on this line, in else statement, not check