사용자입력받기.html 859 Bytes
<!DOCTYPE html>

<html lang="ko">
  <head>
    <meta charset="utf-8">
    <title>123</title>
  </head>

  <body>
    <button type="button" onclick = "myFunction()" name="button">click this</button>
    <div id="div1">
      <h1>안녕하세요</h1>
    </div>

    <input type="text" name="" value="" id="input1">
    <button type="button" onclick="myFunction2()" name="button">click this</button>
    <div id="div2">

    </div>
    <script type="text/javascript">
    "use strict";
    function myFunction(){
    var name = prompt("Enter your Name", "Name");
    var t = document.getElementById("div1");
    t.innerHTML = "<h1>"+name+"</h1>";
  }
  function myFunction2(){
    var name = document.getElementById("input1").value;
    var div = document.getElementById("div2");
    div.innerHTML = "<h1>"+name+"</h1>";
  }




    </script>
  </body>
</html>