Jump to content

Recommended Posts

Javascript timer not displaying correctly. It has always displayed properly , but today out of nowhere its just not working  

the hours and the minutes are not working but  , the seconds are counting down. 

 

I am new to web development 

 

 

this is the    CDN and the external ref  to the countdown timer 

 

<script type="text/javascript" src= "http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="countdown.jquery.js"></script> <!-- this is countdown timer script" <!-->
<script src="script.js"></script>      <!-- this is where countdown timer is refences and where i change the date" <!-->
 

below is the  <script src="countdown.jquery.js">

(function($){




$.fn.countdown = function(options){




var settings={'date':null};


if(options){


$.extend(settings,options);
}


this_sel= $(this);


function count_exec(){


eventDate=Date.parse( settings['date']) / 1000;


currentDate= Math.floor($.now()/1000);


seconds=eventDate -currentDate;


days = Math.floor(seconds / (60 * 60 * 24));
seconds -= days * 60 * 60 * 24;


hours = Math.floor(seconds / (60 * 60));
seconds -= hours * 60 * 60;


minutes = Math.floor(seconds/60);
seconds -= minutes * 60;


















this_sel.find('.days').text(days);
this_sel.find('.hours').text(hours);
this_sel.find('.mins').text(hours);
this_sel.find('.secs').text(seconds);








}




count_exec();


interval=setInterval(count_exec,1000);




}








}) (jQuery);

this is the jquery file   <script src="script.js"></script>

 

$(document).ready(function(){


$('#countdown').countdown({date: '26 January 2014 10:00:00'});




});
 
Edited by hms556

Problem appears in this section where hours is listed twice instead of minutes.

this_sel.find('.days').text(days);
this_sel.find('.hours').text(hours);
this_sel.find('.mins').text(hours);
this_sel.find('.secs').text(seconds);

should be:

this_sel.find('.days').text(days);
this_sel.find('.hours').text(hours);
this_sel.find('.mins').text(minutes);
this_sel.find('.secs').text(seconds);
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.