Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7884913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:55:37+00:00 2026-06-03T04:55:37+00:00

i have some radio buttons with class = active <div id=radioset1> <input type=radio class=active

  • 0

i have some radio buttons with class = active

  <div id="radioset1">
   <input type="radio" class="active" id="radio1" name="radio" />
   <input type="radio" class="active" id="radio2" name="radio" />
   <input type="radio" class="active" id="radio3" name="radio" />
  </div>
  <div id="counter_up">xy</div>

I want to add a timer to the div “counter_up” to show when was the last change of the radiobutton.

therefore i added some jquery code like this:

  $('.active').click(function() {

    clearInterval(myInterval);
    var counter = 0;
    var myInterval = setInterval(function() {

      ++counter;
      $('#counter_up').html('Aktiv seit ' + counter + ' Sekunden');

    },1000);

 });

my code is working, so when i click one of the radio buttons the first time everything works fine.

the problem is, when i click another radio button, the var counter dont starts with 0.

I tried to use delete var and clearInterval, but it doesnt work.
can somebody help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:55:39+00:00Added an answer on June 3, 2026 at 4:55 am

    You should set myInterval globally and restructure your code a bit to make it counting from 0:

    var myInterval = null;
    $('.active').click(function() {
    
        clearInterval(myInterval);
        var counter = 0;
        var timer = function() {
            $('#counter_up').html('Aktiv seit ' + (counter++) + ' Sekunden');
        };
        timer();
        myInterval = setInterval(timer, 1000);
    
    });​
    

    DEMO: http://jsfiddle.net/x3Z6C/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two radio buttons <div align=center class=radio_group> <input type=radio id=gallerymenustyle1 class=element radio name=gallerymenustyle[]
I have html: <div class=box> <input name=radio-1 value=1 type=radio class=radio> <div class=hidden_box> some content
I have some radio buttons in a form: <div id=data_id-block> <dt id=data_id-label><label class=required>Data</label></dt> <dd
I have 3 radio buttons which hide/show some div's. The radio buttons are getting
I have a jsp where some radio buttons and textboxes depend on dropdown selection.
I have some options for pricing using radio buttons. When a user selects the
I have a set of radio buttons. In some cases I want the user
I need some help. I have a div inside which there are some radio
I have some radio buttons that are created dynamically with javascript. I need to
I am using jQuery to customize some radio buttons. I have two different radio

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.