+ 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 Answers
+ 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. đ