js-clickNumCount.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="button" id="submit" value="clickMe">
<select name="" id="select">
<option value="">option1</option>
<option value="">option2</option>
<option value="">option3</option>
</select>
</body>
<script>
var count1 = 0,
count2 = 0;
document.getElementById('submit').addEventListener('click',function(){
count1++;
console.log("您已经点击button" + count1 + "次");
if(count1>1){
alert("button超出点击次数!")
}
})
document.getElementById('select').addEventListener('click',function(){
count2++;
console.log("您已经点击select" + count2 + "次");
if(count2>8){
alert("select超出点击次数8!")
}
})
</script>
</html>
上一篇:Python 实现 Hangman 小游戏


下一篇:[Effective JavaScript 笔记]第27条:使用闭包而不是字符串来封装代码