html - from an input field to an output div- javascript -


<script>     function func()     {         document.getelementbyid("demo").innerhtml = document.getelementbyid("demo").innerhtml + "drew";     } </script> 

with code of mine intended add word "drew" @ end of whole text in <div> id="demo" on button click appeared before <div> in html code. desired output showed fraction of second , again value in <div> restored before function call. have got no clue how solve issue, yet, guess happened because div appears again in code, after button clicked, , changes value initial one.so seek here.

this works fine. may need call way. check if using right way?

function func()  {    document.getelementbyid("demo").innerhtml = document.getelementbyid("demo").innerhtml + "drew";  }
<div id="demo">you </div>  <button onclick="func()">check</button>


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -