hms556 Posted January 3, 2014 Share Posted January 3, 2014 (edited) 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 January 3, 2014 by hms556 Quote Link to comment Share on other sites More sharing options...
hms556 Posted January 3, 2014 Author Share Posted January 3, 2014 (edited) could it be setinterval? im clueless google chrome console says "event.returnValue is deprecated. Please use the standard event.preventDefault() instead." Edited January 3, 2014 by hms556 Quote Link to comment Share on other sites More sharing options...
hansford Posted January 5, 2014 Share Posted January 5, 2014 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); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.