+ 4
How would we change the text on the press of a button in HTML.
I am making something and I want it to swap between two different sets of text. So like, it may say “Hello” when you push one button, and when you press the other, it says “goodbye”. But I want it to be interchangeable and not get stuck on one of the two. So you can swap back and forth. Any help is appreciated, thanks.
5 Respostas
+ 3
well we recommend you try and show where you fail, then you get help.
-------------Anyways use javascript or Jquery-----@@@
e. g
{Html}
<button class="btn btn-primary" id="sayhello" onclick="toggleSayhello()">Hello</button>
{Javascript}
function toggleSayhello(){
var x = document.getElementById("sayhello");
if(x.value =="Hello"){
x.innerHTML = "Hi";
}Else{
x.innerHTML="Hello";
}
}
something like that.... I didn't test though
+ 2
I didn’t even know where to start, that’s why I’m asking you guys.
+ 2
why @Goner
+ 1
@Goner
Sorry it took so buddy. I will be sure to decline them in just a few seconds. 😉