+ 4

Can anyone tell my what is the problem in my code 'Safra'?

I want to make button when I click on it value 'a' appear in textarea in HTML web.

23rd Mar 2017, 1:52 AM
Kirollos Ayman
4 Answers
+ 4
thanks very much for your answer
23rd Mar 2017, 7:51 AM
Kirollos Ayman
+ 4
there is a same problem again
23rd Mar 2017, 8:45 AM
Kirollos Ayman
+ 2
//This example will type an "a" in on each click if you only want it to happen once just tell me <!DOCTYPE html> <html> <head> <title>Page Title</title> <script> function popText() { document.getElementById("demo").innerHTML += "a"; } </script> </head> <body> <textarea id="demo"></textarea> <br /> <button onclick="popText()">Go</button> </body> </html>
23rd Mar 2017, 4:38 AM
sniperisdemoman
sniperisdemoman - avatar
+ 1
try putting them into variables: (declare them outside the click function ) var myArea = document.getElementById("demo"); var appendedText = "a"; then inside the click function do this: myArea.innerHTML += appendedText;
23rd Mar 2017, 4:15 PM
YafiWebDev
YafiWebDev - avatar