Skip to content

DOM-Events #51

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 1 commit into from
Jan 30, 2023
Merged
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
13 changes: 13 additions & 0 deletions JavaScript/Advance/DOM/8. DOM Events/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
h1 {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

h2 {
font-family: monospace;
}

h4 {
font-size: 40px;
width: 200px;
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.
27 changes: 27 additions & 0 deletions JavaScript/Advance/DOM/8. DOM Events/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!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 Events</title>
<link rel="stylesheet" href="css/style.css">
</head>

<body>
<h1>DOM Events</h1>
<h2>Example One</h2>
<h3 onclick="DisplayOne()" id="textOne">Click on this text!</h3>
<h2>Example Two</h2>
<button onclick="DisplayTwo()">The Time is</button>
<p id="textTwo"></p>
<h2>Example Three</h2>
<button onclick="DisplayThree()">Click to see if Cookies are enabled or not</button>
<p id="textThree"></p>
<h2>Example Four</h2>
<h4 id="hover" onmouseover="DisplayFour()">Hove Me</h4>
<script src="script.js"></script>
</body>

</html>
37 changes: 37 additions & 0 deletions JavaScript/Advance/DOM/8. DOM Events/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
let textOne = document.getElementById('textOne');

function DisplayOne() {
textOne.innerHTML = "OOPs!";
}

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

function DisplayTwo() {
textTwo.innerHTML = new Date();
}

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

function DisplayThree() {
var text = "";
if (navigator.cookieEnabled == true) {
text = "Cookies are enabled.";
} else {
text = "Cookies are not enabled.";
}
textThree.innerHTML = text;
}

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

function DisplayFour() {
let x = true;
if (x == true) {
hover.style.backgroundColor = '#00FF00';
x = false;
} else {
hover.style.backgroundColor = 'white';
x = true;
}

}