im actually new to scripting and i am planning to do my own blog site (with my own touch) but it seems i've stumbled upon a roadblock..
the thing is, i wanted a button that changes the text that shows up on screen, and i have successfully did that by using a code that i borrowed from w3schools lol..
here is the code that i used: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_toggle_text
it swapped the text by clicking on a button.. now the question is, would i be able to change the swapped text with another text just by clicking on the same button again? cuz that's what i am initially going for.
You have to use else if statement continuously
function myFunction() {
var x = document.getElementById("myDIV");
if (x.innerHTML === "Hello") {
x.innerHTML = "Swapped text!";
} else if (x.innerHTML === "Swapped text"){
x.innerHTML = "Some another text...";
} else if (x.innerHTML === "Some another text..."){
x.innerHTML = "Again some text";
}
}
Like this you have to continue, if you have multiple texts
I hope you understood and am a beginner in these. Thank You