0
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8s">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<input id="text1" type="text"><br>
<input id="text2" type="text">
<button id="button" type="button">click</button>
<script>
let text1 = document.querySelector("#text1");
let text2 = document.querySelector("#text2");
let button = document.querySelector("#button");
button.addEventListener("click", function() {
text2.textContent = text1.textContent;
});
</script>
</body>
</html>
I’m creating a code in javascript and it aims to grab the text of the first field and play in the second field when the button is clicked, but when I click the button none of this happens and also does not return any error in the console
browser, what I’m doing wrong?