jQuery countdown - Remove highlightLast5 color when time is reset
Hi
I'm using the Countdown timer code I found here: keith-wood.name/countdown.html
Its quite comprehensive in its features however I've one little problem.
I've got a form which sets the time for the countdown and if the time is less than 5 minutes it turns red. However if the time runs out and is reset or is reset after its within the 5 minute mark the text stays red instead of going back to black. I tried adding a simple else statement to the highlightLast5 statement but this hasn't add any effect. Does anybody here have any suggestions?
highlightLast5 function:
-
- function highlightLast5(periods) {
- if ($.countdown.periodsToSeconds(periods) <= 300) {
- $(this).addClass('highlight')
- } else {
- $(this).removeClass('highlight')
- };
- };
Here is the code that creates the initial timer (there's a bit of Ajax before it that I haven't included)
- success: function(examlength) {
- if (countdownExists <= 0) {
- $('#pauseResume').countdown({
- until: examlength,
- onTick: highlightLast5,
- format: 'HMS'
- });
- countdownExists = countdownExists + 1;
- } else {
- $('#pauseResume').countdown('destroy');
- $('#pauseResume').countdown({
- until: examlength,
- onTick: highlightLast5,
- format: 'HMS'
- });
- }
- }