js-clickNumCount.html

时间:2022-04-19 21:43:33
<!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>