0
我使用This Timer Plugin創建一個定時器,一旦單擊按鈕。您可以see it in action here.如果您注意到,當您單擊任何購買按鈕兩次時,它將被忽略並不會再次執行。我無法弄清楚如何解決這個問題。我需要定時器在計時器完成後隨時點擊按鈕重新啓動。定時器插件在執行一次後將無法工作
這裏是我使用的第一個按鈕的HTML:
<h3 class="protection"><span id="sentryTime">00:00:00</span><a href="javascript:sentry()">Purchase Sentry</a></h3>
,這裏是我使用該按鈕它調用插件創建計時器的JavaScript:
function sentry() {
var dateCreated1 = new Date();
setCharacterTime(/*hr*/0,/*min*/0,/*sec*/5,/*title*/'sentryTime',dateCreated1)}
function setCharacterTime(hours, minutes, seconds, title, creationDate) {
var thisDay = creationDate;
var year = thisDay.getFullYear();
var month = thisDay.getMonth();
var day = thisDay.getDate();
var aHour = thisDay.getHours();
var aMinutes = thisDay.getMinutes();
var aSeconds = thisDay.getSeconds();
var aMilli = thisDay.getMilliseconds();
thisDay = new Date(year, month, day, aHour + hours, aMinutes + minutes, aSeconds + seconds, aMilli);
$('#' + title).countdown({until: thisDay, format: 'HMS', layout: ' {hnn}{sep}{mnn}{sep}{snn}', expiryText: 'complete '});
;} //end setCharacterTime() function
如果你需要看的jQuery插件,you can find it live here.
我仍然需要幫助! –