Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Java Script LEVEL 10 LESSON 7

Please Help
by

1 Answer

kshitijrana14
Try this one

<!doctype html>
<html>
<head>
<title>JS Event handling</title>
</head>
<body>
<button id="myBtn">Do Wonders!</button>
<script>
// find the btn in DOM
let btn = document.getElementById("myBtn");
// add style to it
btn.style.padding = "10px";

// add event listener
btn.addEventListener('mouseover',changeColor)
function changeColor()
{
btn.style.backgroundColor = "red";
}
</script>
</body>
</html>

Login / Signup to Answer the Question.