+ 1
Javascript DOM
i wanna make an alert button when you keep clicked it, the number increas. ex: first alert : "You clicked 1 time" second alert : "You clicked 2 times" third alert:"You clicked 3 times" and so on sorry for my poor english, i hope you can understand me
5 Réponses
+ 3
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<button>click</button>
<script>
let count = 1;
let btn = document.querySelector("button")
btn.addEventListener("click",()=>{
alert(`You click ${count}`)
count++;
})
</script>
</body>
</html>
+ 6
You may refer to this
https://www.tutorialspoint.com/How-to-display-JavaScript-variable-value-in-alert-box
+ 2
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<button onclick="ClickMe()">ClickMe</button>
</body>
</html>
var count1 = 1;
var count2 = 1;
function ClickMe(){
if(count1 == count2 ){
alert(count2);
count1++;
count2 = 0;
}
count2++;
}
+ 2
idea thief Try this
0
...can you guys kindly explain to me from line to line please