How to Create an Alert Offers Bar in WordPress Free

Subscribe our YouTube Channel    

CSS Code


.offerbar { 
    background-color: #ff6600; 
    color: #FFFFFF; 
    display: block; 
    line-height: 45px;
    height: 50px; 
    position: relative; 
    text-align: center; 
    text-decoration: none; 
    top: 0px; 
    width: 100%;
    z-index: 100;
}

HTML Code


<div class="offerbar"> YOUR TEXT HERE <span id="igtm"></span><div>

JavaScript Code


<script>
// Set the date we're counting down to
var countDownDate = new Date("Jan 5, 2021 15:37:25").getTime();

// Update the count down every 1 second
var x = setInterval(function() {

  // Get today's date and time
  var now = new Date().getTime();
    
  // Find the distance between now and the count down date
  var distance = countDownDate - now;
    
  // Time calculations for days, hours, minutes and seconds
  var days = Math.floor(distance / (1000 * 60 * 60 * 24));
  var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  var seconds = Math.floor((distance % (1000 * 60)) / 1000);
    
  // Output the result in an element with id="igtm"
  document.getElementById("igtm").innerHTML = days + "d " + hours + "h "
  + minutes + "m " + seconds + "s ";
    
  // If the count down is over, write some text 
  if (distance < 0) {
    clearInterval(x);
    document.getElementById("igtm").innerHTML = "EXPIRED";
  }
}, 1000);
</script>

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

Hey, I’m Bharat Makwana, A Full Time Blogger & Youtuber, Founder of InfinityGyan, Bloggingguidance, Veewom and BM Tech Tips YouTube Channel.

You may also like this!