javascript - How to have an element fade out and another element fade in in its place on window load? -


i trying create splash screen website , have made progress bar make nicer. have links user login or register.

what want achieve is, right after window loads, have progress bar thing 4 seconds have fade out in .5 seconds , have links fade in in place in .5s total of 5 seconds before user can proceed.

i have put code make work using mainly:

settimeout(); 

but despite having no errors far both , google chrome console can tell, no visible result produced.

how can fix code work properly? suggestions appreciated. prefer solution in plain javascript, if there's no other way, satisfied jquery 1 too.

to you, have assembled demo here.

no doubt switch jquery. fadein , fadeout easily:

$(window).load(function(){      var t=settimeout(function(){    $("#progressbar").fadeout(500);    $("#splashscreen-links").fadein(500);    },4000)      })
@-webkit-keyframes greenglow {      {          left:-120px;      }      {          left:100%;      }  }    @-moz-keyframes greenglow {      {          left: -120px;      }      {          left: 100%;      }  }    @-ms-keyframes greenglow {      {          left: -120px;      }      {          left: 100%;      }  }    @-o-keyframes greenglow {      {          left: -120px;      }      {          left: 100%;      }  }    @keyframes greenglow {      {          left: -120px;      }      {          left: 100%;      }  }    #progressbar {      /* dimensions */      width: 250px;      height: 16px;      overflow: hidden;            /* positioning */      position: absolute;      top: 50%;      left: 50%;      -webkit-transform: translate(-50%, -50%);      -o-transform: translate(-50%, -50%);      -ms-transform: translate(-50%, -50%);      -moz-transform: translate(-50%, -50%);      transform: translate(-50%, -50%);      margin: 5px;      padding-top: 4px;      padding-left: 17px;            /* styling */      background: #e6e6e6;      border:1px solid #bbb;      border-radius:0px;  }    #progressbar:after {      content: " ";      display: block;      width: 120px;      top: -50%;      height: 250%;      position: absolute;      animation: greenglow 2s linear infinite;      -webkit-animation: greenglow 2s linear infinite;      z-index: 2;      background: #1cae30;  }    #splashscreen-links {      /* text */      color: #999999;      font-family: "arial";      text-decoration: none;            /* positioning */      position: absolute;      top: 50%;      left: 50%;      -webkit-transform: translate(-50%, -50%);      -o-transform: translate(-50%, -50%);      -ms-transform: translate(-50%, -50%);      -moz-transform: translate(-50%, -50%);      transform: translate(-50%, -50%);      margin: 5px;      padding-top: 4px;      padding-left: 17px;            /* visibility */      display: none;  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <div id="progressbar"></div>  <p id = "splashscreen-links"><a>login</a>&nbsp;&bull;&nbsp;<a>register</a></p>


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

python 3.x - PyQt5 - Signal : pyqtSignal no method connect -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)