如何在单击按钮时显示文本

时间:2014-09-02 13:45:36

标签: ajax

<html>
   <head>
     <script>
       function loadXMLDoc()
       {
          Welcome To Ajax
       }
     </script>
   </head>
   <body>
      <div id="myDiv"><h2>Let AJAX change this text</h2></div>
      <button type="button" onclick="loadXMLDoc()">Change Content</button>
   </body>
</html>

点击按钮时如何显示文字。点击按钮时如何显示文字?

1 个答案:

答案 0 :(得分:0)

 function loadXMLDoc()
   {
     document.getElementById("myDiv").innerHTML = "<h2>Welcome To Ajax</h2>"
   }