Javascript examples for DOM HTML Element:Div
Use div to display function result
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> function showAnswer(){//from w ww . java 2 s.co m document.getElementById("ans").innerHTML="This is the answer"; } </script> </head> <body> <div id="q"> This is a question? <button onclick="showAnswer()">Show Answer</button> </div> <div id="ans"> </div> </body> </html>