JavaScript How to automatically make content change?

I have created this block of code. It works in a way that if you click one of the cirles, it gets activated and the content corresponding to the circle is show. How can I make this change automatically so that, for example, every 5 seconds another circle gets activated with its corresponding content shown. I want to make this loop never ending.

<html>
  <head>
     <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
     <style>
        #timeline{height:460px;width:3px;background-color:#E6E6E6;position:absolute;left:50%;top:55px;}

        a.cirle{width:15px;height:15px;background-color:#E6E6E6;border-radius:50px;position:absolute;}
        a.cirle:hover{background-color:red;}
        a.cirle.active{background-color:red;}

        .contentquestion1{position:absolute;top:35px;margin-left:-7px;left:50%;}
        .contentquestion2{position:absolute;top:225px;margin-left:-7px;left:50%;}
        .contentquestion3{position:absolute;top:425px;margin-left:-7px;left:50%;}

        #contentanswer {position: absolute;left: 50%;top: 200px;margin-left: 50px;}
        #contentanswer1 {position: absolute;left: 50%;top: 200px;margin-left: 50px;display:none;}
        #contentanswer2 {position: absolute;left: 50%;top: 200px;margin-left: 50px;display:none;}
        #contentanswer3 {position: absolute;left: 50%;top: 200px;margin-left: 50px;display:none;}
     </style>
  </head>
  <body>      
     <div id="timeline"></div>
     <script type='text/javascript'>//<![CDATA[
            $(window).load(function(){
            $('[class^="contentquestion"]').on('click', function(e){
                e.preventDefault();
                var numb = this.className.replace('contentquestion', '');
                $('[id^="contentanswer"]').fadeOut(500);
                $('#contentanswer' + numb).fadeIn(500);
            });
            });//]]> 
     </script>
     <script type='text/javascript'>
            $(function() {
               $('a.cirle').click(function() {
                   $('a.cirle').removeClass('active');
                $(this).addClass('active');
               }).eq(1).addClass('active');
            });
     </script>
     <div class="timeline timeline1">
        <div class="contentquestion1"><a class="cirle" target='_blank' href="#"></a></div>
        <div class="contentquestion2"><a class="cirle" target='_blank' href="#"></a></div>
        <div class="contentquestion3"><a class="cirle" target='_blank' href="#"></a></div>
     </div>   

     <div class="new_member_box_display" id="contentanswer">CONTENT 2</div>
     <div id="contentanswer1">CONTENT 1</div>
     <div id="contentanswer2">CONTENT 2</div>
     <div id="contentanswer3">CONTENT 3</div>
  </body>
</html>

Codepen: http://codepen.io/anon/pen/BoWZgY

Answer:1

Add this to your code:

jQuery.fn.random = function () {
          var randomIndex = Math.floor(Math.random() * this.length);
          return jQuery(this[randomIndex]);
      };

      setInterval(function () {
          $('.cirle:not(".active")').random().click();
      }, 2000);
Answer:2

On many of my EJS pages I have the following code: <%- include('elements/fbviewpagepixel.ejs') %> It works perfectly fine except on this one page. On that one pages it gives me an error saying ...

On many of my EJS pages I have the following code: <%- include('elements/fbviewpagepixel.ejs') %> It works perfectly fine except on this one page. On that one pages it gives me an error saying ...

  1. function include error

using nodejs and express I'm trying to trigger a js function which contains a simple console log. Sadly the function only triggers 6 times and freezes for a while. After a minute or two all the button ...

using nodejs and express I'm trying to trigger a js function which contains a simple console log. Sadly the function only triggers 6 times and freezes for a while. After a minute or two all the button ...

  1. node js express ajax tutorial
  2. node js express ajax request
  3. nodejs express ajax post
  4. nodejs express ajax call
  5. nodejs express ajax get
  6. node js express ajax
  7. node.js express ajax example
  8. node.js express ajax post example
  9. node.js express ajax file upload
  10. node.js express ajax json
  11. node.js express jquery ajax
  12. javascript ajax node js express

My question has two parts here: I have created an Instagram clone and would like to be able to click on each individual image and have a like feature. The way that I currently have this set up is by ...

My question has two parts here: I have created an Instagram clone and would like to be able to click on each individual image and have a like feature. The way that I currently have this set up is by ...

How can I localize current day and month (without year) in moment.js? What I want is exactly the output of moment().format('LL') but without the year part. Consider the following example: moment()....

How can I localize current day and month (without year) in moment.js? What I want is exactly the output of moment().format('LL') but without the year part. Consider the following example: moment()....