0
我想啓用第二個按鈕,只有在第一個按鈕被點擊後才能被點擊。我想要啓用的按鈕是JS中的啓動變量。這是我做的:如何在發生特定操作後添加onclick事件處理程序?
<!--One of these "buttons" has to be clicked to enable clicking of another one-->
<li id="easy" class="list" onclick="shadows(1)">Easy</li>
<li id="medium" class="list" onclick="shadows(2)">Medium</li>
<li id="hard" class="list" onclick="shadows(3)">Hard</li>
<!--it goes to another function shadows()-->
下面是函數:
function shadows(number){
start.style.cursor="pointer";
shadow=1;//I set a variable to 1(It was previously 0)
start.style.backgroundColor="#ffffb3";
start.onmouseenter=function(){
start.style.backgroundColor="yellow";
};
start.onmouseleave=function(){
start.style.backgroundColor="#ffffb3";
};
}
我後來檢查,如果影子變量是1
if(shadow==1){
start.onclick=function(){
easy.style.display="none";
medium.style.display="none";
hard.style.display="none";
randomExercise();
};
}
我嘗試添加onclick事件,但它不起作用。點擊按鈕時沒有任何反應。我怎樣才能解決這個問題?
所以你希望媒體只有在輕鬆點擊等後纔可以訪問? –
@Erik好像我已經得到了答案。我想在點擊列表中的任何項目後出現「開始」按鈕。 –