I am not very strong in JS, help please solve the issue. There is a div that needs to be displayed every 5 minutes

Inactive div

<div class="ibx-wpfomo-floating-popup" style="display: none; bottom: 90px; opacity: 0;"> 

Active div

 <div class="ibx-wpfomo-floating-popup" style="display: block; bottom: 100px; opacity: 1;"> 

As I understand it, everything is simple: I need to change css c display: none to display: block using setInterval. But for some reason the code does not work.

My code: (I insert it into custom JS in the theme settings)

  jQuery(window).load(function(){ setTimeout(function (){ $('.ibx-wpfomo-floating-popup').css('display', 'block'); }, 1000) }); 

I would be grateful for the tips :)

    2 answers 2

    An example with the addition of the show class and corresponding styles:

     $(window).load(function(){ setTimeout(function (){ $(".ibx-wpfomo-floating-popup").addClass('show'); }, 1000); }); 
     .ibx-wpfomo-floating-popup { display: none; bottom: 90px; opacity: 0; } .ibx-wpfomo-floating-popup.show { display: block; opacity: 1; } 
     <script src="https://code.jquery.com/jquery-2.2.4.js"></script> <div class="ibx-wpfomo-floating-popup" >Popup</div> 

    • one
      Thank! Everything worked out! - user330660 pm

    If you yourself write that you need to use setInterval , then why use setTimeout ? The display switched from none to block using the toggle method.

     setInterval(function(){ $(".ibx-wpfomo-floating-popup").toggle(true); }, 5*1000);