Skip to content

Main #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 1, 2023
Merged

Main #52

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions JavaScript/Advance/DOM/9. DOM Event Listener/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
h2 {
font-family: monospace;
}

div {
width: 300px;
height: 300px;
border: 1px solid black;
text-align: center;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions JavaScript/Advance/DOM/9. DOM Event Listener/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DOM Event Listner</title>
<link rel="stylesheet" href="css/style.css">
<link src = "images/js-logo.png">
</head>

<body>
<h1>DOM Event Listener</h1>
<h2>Example One</h2>
<div id="exampleOne">
<h2>OnClict Event</h2>
</div>
<h2>Example Two</h2>
<div id="exampleTwo">
<h2>On Mouse Over</h2>
</div>
<h2>Example Three</h2>
<div id="exampleThree">
<h2>On Mouse Out</h2>
</div>
<script src="script.js"></script>
</body>

</html>
34 changes: 34 additions & 0 deletions JavaScript/Advance/DOM/9. DOM Event Listener/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Example One
let exampleOne = document.getElementById('exampleOne');

exampleOne.addEventListener("click", () => {
exampleOne.style.backgroundColor = "Green";
exampleOne.style.color = "white";
});


// Example Two
let exampleTwo = document.getElementById('exampleTwo');

exampleTwo.addEventListener("mouseover", () => {
exampleTwo.style.backgroundColor = "Blue";
exampleTwo.style.color = "White";
});
exampleTwo.addEventListener("mouseout", () => {
exampleTwo.style.backgroundColor = "white";
exampleTwo.style.color = "Green"
});

// Example Three

let exampleThree = document.getElementById('exampleThree');

exampleThree.addEventListener("mouseover", () => {
exampleThree.style.backgroundColor = "purple";
exampleThree.style.Color = "white";
})

exampleThree.addEventListener("mouseout", () => {
exampleThree.style.backgroundColor = "white";
exampleThree.style.color = "purple";
})