Basic dom - II
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>replit</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<button>click Me</button>
<button>click e</button>
<button>click M</button>
<script src="index.js"></script>
</body>
</html>
---------------------------------------------------------------------------------
let btns = document.querySelectorAll("button")
for (btn of btns){
btn.onclick = sayHello;
btn.onmouseenter = function(){
console.log("you enter a btn");
}
}
function sayHello(){
alert("Hello")
}
Comments
Post a Comment