Use div to display function result - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Div


Use div to display function result

Demo Code

ResultView the demo in separate window

      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
function showAnswer(){//from w  ww  . java  2  m
    document.getElementById("ans").innerHTML="This is the answer";

      <div id="q">
          This is a question? 
         <button onclick="showAnswer()">Show Answer</button> 
      <div id="ans"> 

Related Tutorials