[英]Clicking one button 5 times or more then activate another button
我試圖在第一個按鈕上點擊 5 次或更多次后激活第二個按鈕。 我怎樣才能做到這一點。
$(function(){
$("#bt1").click(function(){
$(this).attr("disabled", "disabled");
$("#bt2").removeAttr("disabled");
});
});
像這樣?
var cnt = 0; $('#btn1').on('click', function() { cnt++; console.log(cnt); //remove this line to not see the count if(cnt >= 5) { $(this).attr("disabled", "disabled"); $("#btn2").removeAttr("disabled"); } });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button id="btn1">Button 1</button> <button id="btn2" disabled>Button 2</button>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.