每当我将两者一起添加时,它会在我的页面上创建一个意外的令牌}。有什么不对,我错过了什么?我看了一切。它似乎都是分开工作的。
此外,当我查看我的控制台时,它会给我一条错误导致的行,但是如果我点击它它什么都没有显示。
有什么想法吗?
$(document).ready(function () {
// On Load Show
$('.draft_landing_wrapper').hide();
$(".light_admin,.dark_gray_overlay").fadeIn("slow", function () {
setTimeout(function () {
$(".light_admin,.dark_gray_overlay").fadeOut("slow");
}, 10000);
$(".light_admin").animate({
paddingBottom: '150px',
paddingTop: '150px',
marginTop: '-150px'
}, function () {
$('.draft_landing_wrapper').delay(1000).fadeIn('fast');
});
});
});
$('.admin_popup').on('click', function () {
$(".light_admin,.dark_gray_overlay").fadeIn("slow", function () {
$(".light_admin").animate({
paddingBottom: '150px',
paddingTop: '150px',
marginTop: '-150px'
});
});
});
$('.draft_close').on('click', function () {
$(".light_admin,.dark_gray_overlay").fadeOut("slow");
$(".light_admin").css({
paddingBottom: '0px',
paddingTop: '0px',
marginTop: '0px'
});
});
然后这个
//Timer
var times = [];
var counter_interval;
var $time_left = $('.time-left');
var $button = $('.start-pause');
$(document).ready(function () {
// timer length in seconds
var timer_length = 45;
$('body').on('click', '.start-pause', function () {
// are we starting or stopping?
var starting = times.length % 2 == 0;
times.push(Date.now());
if (starting) {
$button.html('Pause');
counter_interval = setInterval(function () {
var time_left = Math.floor(timer_length - sum_elapsed());
if (time_left < 1) {
clearInterval(counter_interval);
return finished();
}
//$time_left.html(time_left);
$time_left.html(secToMinTxt(time_left));
}, 100);
} else {
$button.html('Resume');
clearInterval(counter_interval);
}
});
function pad(num) {
var str = "" + num;
var pad = "00";
return pad.substring(0, pad.length - str.length) + str;
}
function secToMinTxt(seconds) {
var min = Math.floor(seconds / 60);
var sec = seconds % 60;
return pad(min) + ":" + pad(sec);
}
var sum_elapsed = function () {
sum = 0;
for (var i = 0; i < times.length; i++) {
if (i % 2 == 1) {
sum += (times[i] - times[i - 1]);
}
if (i == (times.length - 1)) {
sum += (Date.now() - times[i]);
}
}
// convert milliseconds to seconds
return sum / 1000;
};
var finished = function () {
$button.attr('disabled', 'disabled').html('Finished');
$time_left.html("Time's Up!!");
};
});
});