Skip to content

Commit

Permalink
add a new project JS Events
Browse files Browse the repository at this point in the history
  • Loading branch information
lenadgit committed Feb 5, 2024
1 parent d5a5e89 commit 1bf78e4
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 0 deletions.
Binary file added jsevents/css/Ujeo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added jsevents/css/grass.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions jsevents/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
html {
box-sizing: border-box;
}

body {
background-image: url('grass.jpg');
}

h1 {
font-size: 40px;
font-weight: 600;
color: #ffffff;
text-shadow: 2px 2px 3px #001a00;
}

p {
color: #ffffff;
font-weight: 600;
}

div {
width: 50%;
padding: 100px;
border-radius: 50%;
margin: 0 auto;
}

.one {
background: #315082;
}

.two {
background: #4a87bf;
}

.three {
background: #6bb4d0;
}

.water {
background-image: url('Ujeo.gif');
background-position: center;
background-size: cover;
display: block;
}

.refresh {
background: #ffffff;
font-size: 18px;
font-weight: 400;
color: #003366;
border: 2px solid #003366;
padding: 6px;
}
55 changes: 55 additions & 0 deletions jsevents/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!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">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>JS Events</title>

<link href="css/style.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/html5shiv.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dest/respond.min.js"></script>
<![endif]-->
</head>
<body>
<h1>Event Bubbling</h1>
<p>Just click on an any one of water rounds to see an bubbling effect</p>

<button class = "refresh">Refresh Button</button>
<div class = "one">
<div class = "two">
<div class = "three"></div>
</div>
</div>

<script>
const divs = document.querySelectorAll('div');
function logText(e) {
console.log(this.classList.value);
this.classList.add('water');
let audio = new Audio();
audio.src = 'water.wav';
audio.autoplay = true;

e.stopPropagation();
};

divs.forEach(div => div.addEventListener('click', logText));

const refreshButton = document.querySelector('.refresh');

const refreshPage = () => {
location.reload();
console.log('click');
};

refreshButton.addEventListener('click', refreshPage, {once: true});

</script>
</body>
</html>
Binary file added jsevents/water.wav
Binary file not shown.

0 comments on commit 1bf78e4

Please sign in to comment.