-1
我想點擊一個div,並有一個JavaScript函數重置 每次我點擊id =「home」按鈕我想countME()和countDE()復位至1/5如何觸發一個功能,點擊一個div id javascript/lQuery
HTML
<button type="button" onClick="countME()">Click up</button>
<button type="button" onClick="countDE()">Click down</button>
<div id="home"><button>home</button></div>
<p>Clicks: <a id="clicks">1</a>/5</p>
JS
var clicks = 1;
function countME() {
clicks += 1;
if(clicks >= 5){
clicks = 5;
}
document.getElementById("clicks").innerHTML = clicks;
}
function countDE() {
clicks -= 1;
if(clicks <= 1){
clicks = 1;
}
document.getElementById("clicks").innerHTML = clicks;
}
帶有id ='home''的元素是div – DDan