+ 2
My button keeps disappearing.
I am making a button that takes the different letters of the string "Hello" and displays it every time a button is clicked. My problem is that the first time my button is clicked, it disappears so I don't get to click it a second time. Each time I click it I want it to concat the letters of "Hello" together adding one letter of a time. I used a which means I probably shouldn't have used a switch function. But for now I just want feedback on how to get my button to not disappear. https://code.sololearn.com/WicKTVVOHsmi/#js
4 odpowiedzi
+ 10
case 0 :string.charAt(0);
break;
case 1:string.charAt(1);
p.innerHTML = string.charAt(1);
break;
case 2: string.charAt(2);
P.innerHTML = string.charAt(2);
break;
case 3:string.charAt(3);
p.innerHTML = string.charAt(3);
break;
case 4:string.charAt(4);
p.innerHTML = string.charAt(4);
break;
+ 11
you are using document.write() function which removes all things you make then write on the web so you need to add paragraph to you Html <p></p> and add ID for it exmaple
<p id="demo" ></p>
then go to js and write
var demo = document.getElementById("demo");
demo.innerHTML = string.charAt(0);
+ 10
C0d!ng K!tty still not working
see you make this
case 0 :string.charAt(0);
break;
case 1:string.charAt(1);
document.write(string.charAt(1));
break;
case 2: string.charAt(2);
document.write(string.charAt(2));
break;
case 3:string.charAt(3);
document.write(string.charAt(3));
break;
case 4:string.charAt(4);
document.write(string.charAt(4));
break;
document.write()
must be
p.innerHTML = ;
+ 2
@Mirage Still not working. What do I replace document.write with if that's the problem?