-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
40 lines (34 loc) · 1.19 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Get references to the elements to be animated
const lucasName = document.querySelector('#lucas');
const remyName = document.querySelector('#remy');
const alertButton = document.querySelector('#alertButton');
const container = document.querySelector('.container');
// Function to add shake animation
function addShakeAnimation(element) {
element.classList.add('shake');
}
// Function to change color
function changeColor(element) {
const colors = ['#ff0000', '#00ff00', '#0000ff', '#ffff00', '#ff00ff', '#00ffff'];
const randomColor = colors[Math.floor(Math.random() * colors.length)];
element.style.color = randomColor;
}
// Function to create explosion effect
function createExplosion() {
const explosion = document.createElement('div');
explosion.className = 'explosion';
container.appendChild(explosion);
setTimeout(() => {
explosion.remove();
}, 1000);
}
// Add shake animation to Lucas and Rémy's names
addShakeAnimation(lucasName);
addShakeAnimation(remyName);
// Add event listeners to change color on click
lucasName.addEventListener('click', function() {
changeColor(this);
});
remyName.addEventListener('click', function() {
changeColor(this);
});