第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

彈出窗口和停止計(jì)數(shù)器需要 JavaScript 幫助

彈出窗口和停止計(jì)數(shù)器需要 JavaScript 幫助

qq_花開花謝_0 2023-11-13 14:57:53
我希望為這個(gè)項(xiàng)目提供一些幫助。我正在使用 Javascript 創(chuàng)建一個(gè)小項(xiàng)目,我對(duì) HTML、CSS 和 JavaScript 仍然很陌生。我想用我的程序做的是,計(jì)數(shù)器將在 1 分鐘過去后停止,并出現(xiàn)一個(gè)彈出窗口,不再接受任何點(diǎn)擊。以下是我的代碼,任何幫助將不勝感激!var count = 0;var countblack = 0;var countred = 0;var countButton = document.getElementById("black");var countButtonC = document.getElementById("red");var displayCount = document.getElementById("displayCount");black.onclick = function() {  count++;  countblack++;  displayCount.innerHTML = count;  displayCountblack.innerHTML = countblack;}red.onclick = function() {  count++;  countred++;  displayCount.innerHTML = count;  displayCountred.innerHTML = countred;}http://jsfiddle.net/wr1ua0db/544/
查看完整描述

1 回答

?
動(dòng)漫人物

TA貢獻(xiàn)1815條經(jīng)驗(yàn) 獲得超10個(gè)贊

您可以使用setTimeout60 秒計(jì)數(shù),然后禁用按鈕。下面是解決方案


var allowClick = true;

var count = 0;

var countblack = 0;

var countred = 0;

var black = document.getElementById("black");

var red = document.getElementById("red");

var displayCount = document.getElementById("displayCount");

var displayBlackCount = document.getElementById("displayBlackCount");

var displayRedCount = document.getElementById("displayRedCount");


black.onclick = function() {

  if (!allowClick) return;


  count++;

  countblack++;

  displayCount.innerHTML = count;

  displayBlackCount.innerHTML = countblack;

}


red.onclick = function() {

  if (!allowClick) return;


  count++;

  countred++;

  displayCount.innerHTML = count;

  displayRedCount.innerHTML = countred;

}


startTime(60); // time in seconds


function startTime(time) {

  var timer = setTimeout(function() {

    black.setAttribute('disabled', 'disabled');

    red.setAttribute('disabled', 'disabled');

    allowClick = false;

    clearTimeout(timer)

  }, 1000 * time)

}

<button id="black">Count Black</button>

<button id="red">Count Red</button>


<div>Display Count: <span id="displayCount">0</span></div>

<div>Black Count: <span id="displayBlackCount">0</span></div>

<div>Red Count: <span id="displayRedCount">0</span></div>


查看完整回答
反對(duì) 回復(fù) 2023-11-13
  • 1 回答
  • 0 關(guān)注
  • 171 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)