Skip to content

Commit 5c0d321

Browse files
committed
Async javascript ...
1 parent 9523d5c commit 5c0d321

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

Async_JavaScript/1st.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Async Javascript with Two Projects</title>
7+
</head>
8+
<body>
9+
<h1 id="name">Waseem Malik</h1>
10+
<button id="stop">stop</button>
11+
</body>
12+
<script>
13+
// console.log("is js working");
14+
// setTimeout(() => {
15+
// console.log("waseem akram");
16+
// }, 2000); //time in milli-seconds=> 1s=1000
17+
// function changeh1() {
18+
// const changeName = document.getElementById("name");
19+
// changeName.innerHTML = "hafiz Fahad iqbal";
20+
// }
21+
22+
// const stop = setTimeout(changeh1, 3000);
23+
24+
// document.querySelector("#stop").addEventListener("click", function () {
25+
// clearTimeout(stop);
26+
// console.log("STOPPED");
27+
// });
28+
</script>
29+
</html>

Async_JavaScript/2nd.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Async Javascript with Two Projects</title>
7+
</head>
8+
<body>
9+
<h1 id="name">M Talha Makhdoom</h1>
10+
<button id="start">start</button>
11+
<button id="stop">stop</button>
12+
</body>
13+
<script>
14+
// console.log("is js working");
15+
// setInterval(() => {
16+
// console.log("waseem akram", Date.now());
17+
// }, 1000);
18+
19+
const sayDate = function (str) {
20+
console.log(str, Date.now()); //you can use default value also just like i passed it as parameter str whcih value is hi
21+
};
22+
const stopInterval = setInterval(sayDate, 1000, "hi");
23+
24+
document.getElementById("stop").addEventListener("click", () => {
25+
clearInterval(stopInterval);
26+
});
27+
</script>
28+
</html>

0 commit comments

Comments
 (0)