+ 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.
4 ответов
+ 4
thanks very much for your answer
+ 4
there is a same problem again
+ 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>
+ 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;