-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathad-hello.js
More file actions
28 lines (27 loc) · 1.04 KB
/
ad-hello.js
File metadata and controls
28 lines (27 loc) · 1.04 KB
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
document.addEventListener('DOMContentLoaded', function () {
let input = document.querySelector('#name');
input.addEventListener('keyup', function(event) {
let name = document.querySelector('#p1');
if (input.value) {
name.innerHTML = `hello, ${input.value}`;
}
else {
name.innerHTML = 'hello, beta kaise ho?';
}
});
let body = document.querySelector('body')
document.querySelector('#red').addEventListener('click', function(){
body.style.backgroundColor = 'rgb(244, 165, 165)';
})
document.querySelector('#blue').addEventListener('click', function(){
body.style.backgroundColor = 'lightblue';
})
document.querySelector('#green').addEventListener('click', function(){
body.style.backgroundColor = 'lightgreen';
})
document.querySelector('form').addEventListener('submit', function(event) {
let color = document.querySelector('#color').value;
body.style.backgroundColor = color;
event.preventDefault();
})
});