代码
提交代码
<style>
.btn {
border: 1px solid #4caf50;
font-size: 14px;
padding: 8px 12px;
color: #4caf50;
outline: none;
}
.btn:active {
background: #eee;
}
</style>
<button class="btn">
按钮
</button>
<script>
var btn = document.querySelector('.btn');
var total = 1;
function fn() {
btn.innerText = ++total;
if (total > 5) {
btn.removeEventListener('click', fn);
}
}
btn.addEventListener('click', fn);
</script>
运行结果