roli roli roli roli - 2 months ago 16
Javascript Question

Disappear InnerHTML after 5 seconds javascript

hello i have the below code It works fine but i want something else.Take a look

<script type="text/javascript">
function myfunction() {
var x = document.forms["forma"]["emri"].value;
var x1 = document.forms["forma"]["mbiemri"].value;
var x2 = document.forms["forma"]["email"].value;
var x3 = document.forms["forma"]["vendbanimi"].value;
if ((x == null || x == "") || (x1 == null || x1 == "") || (x2 == null || x2 == "") || (x3 == null || x3 == "") ) {
document.getElementById("js").innerHTML = "Ju lutem ploresojini te gjitha te dhenat";
return false;
if (x2.indexOf("@") < 1) {
document.getElementById("js").innerHTML = "Ju lutem insertoni nje email te sakte";
return false;

This is my html

<div class="forma">
<form class="form-orizontal" method="post" name="forma">
<div class="input-prepend">
<span class="add-on">e</span>
<input class="span2" id="prependedInput" type="text" placeholder="emri" name="emri">
<div class="input-prepend">
<span class="add-on">mb</span>
<input class="span2" id="prependedInput" type="text" placeholder="mbiemri" name="mbiemri">
<div class="input-prepend">
<span class="add-on">@</span>
<input class="span2" id="prependedInput" type="text" placeholder="email" name="email">
<div class="input-prepend">
<span class="add-on">vb</span>
<input class="span2" id="prependedInput" type="text" placeholder="vendbanimi" name="vendbanimi">
<div class="input-prepend">
<span class="add-on">V</span>
<select name="viti_lindjes" class="small">
<option style="display:none">Viti i lindjes</option>
<div class="control-group">
<div class="controls">
<button type="submit" class="btn" name="submit" onclick="return myfunction()">Submit</button>
<input type="reset" class="btn">
<div id="js"></div>

It's work fine but i want to disappear the innerHTML after 5 seconds.Not every 5 sec but when it appear,after 5 sec to disappear.Once!


setTimeOut function waits for you

function appearing(){
  document.getElementById("inner").innerHTML = "Paragraph changed!";
      document.getElementById("inner").innerHTML = "";
  }, 5000);
<a href='#' onClick='appearing()'>Appear and disapper after 5 seconds</a>
<div id='inner'></div>