-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
29 lines (24 loc) · 780 Bytes
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPE html>
<html>
<head>
<script>
function copyText()
{
// create a p tag and text node
var newP = document.createElement("p");
var newText = document.createTextNode("Oh hai, I'm dynamically generated.");
newP.appendChild(newText); // add text to created p tag
// add p tag and text element to list of text updates in textArea
var textArea = document.getElementById("field2");
document.body.insertBefore(newP, textArea);
}
</script>
</head>
<body>
Field1: <input type="text" id="field1" value="Hello World!"><br>
Field2: <input type="text" id="field2">
<br><br>
<button onclick="copyText()">Copy Text</button>
<p>A function is triggered when the button is clicked. The function copies the text from Field1 into Field2.</p>
</body>
</html>