<!DOCTYPE html> <html lang="ja"> <head> <title>回数</title> </head> <body> <h1>記録は</h1> <form name="form1"> <input type="text" name="input1"> <input type="button" id="test1" value="実行"> </form> <h2><p id="test2"> </p></h2><h2>回です。</h2> <script> function func1() { let y = document.form1.input1.value; const z = document.querySelector("#test2"); z.textContent = y; } const x = document.querySelector("#test1"); x.addEventListener("click",func1); </script> </body> </html>