javascript - My div Element Is Gone After page refresh Help me -


<script>  function create()  {      var div = document.createelement('div');      div.textcontent = document.getelementbyid('text').value;      div.setattribute('class', 'note');      document.body.appendchild(div);      div.style.background="yellow";      div.style.width="300px";      div.style.height="100px";      if(document.getelementbyid('text').value=="")      {         div.parentnode.removechild(div);          alert("plz put text");     } }  </script>  <body>  <input type="button" onclick="create()" value="create"/>  <input type="text" id="text" />  </body> 

problem in line.

<input type="text" id="text" /> 

because have checked condition

if(document.getelementbyid('text').value=="") 

but did not give value id="text".

try . <input type="text" id="text" value="user" />


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -