-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.html
125 lines (103 loc) · 3.01 KB
/
events.html
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!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>Document</title>
<style>
body {
background-color: rgb(176, 176, 92);
}
div{
height:500px ;
width:500px;
background-color: cadetblue;
margin: auto;
}
button{
background-color: brown;
margin: 48%;
}
</style>
</head>
<body >
<!--
<button id="btn" >Click Me!</button>
<input type="text" id="inp" onchange="uprcase(this)">
<p id="para" onmouseover="moveOver(this)">This is a paragraph.</p>
-->
<div id="d">
<button id="b">CLICK ME!</button>
</div>
<script>
let div = document.getElementById('d');
let btn = document.getElementById('b');
btn.addEventListener('click',btnClick);
div.addEventListener('click',divClick);
document.body.addEventListener('click',bodyClick);
function btnClick(event){
console.log('button clicked');
event.stopPropagation();
}
function divClick(){
console.log('div clicked');
}
function bodyClick(){
console.log('body clicked');
}
/* //*****DOM EVENTS*****
let inp=document.getElementById('inp');
function uprcase(x){
x.value=x.value.toUpperCase();
}
let para = document.getElementById('para');
function moveOver(obj){
obj.innerHTML = 'Thank You';
obj.style.backgroundColor = 'red';
}
para.addEventListener('mouseout',function(){
this.innerHTML= 'Back Again';
this.style.backgroundColor = 'white';
})
function btnClick(){
alert("Button Clicked");
}
let btn = document.getElementById("btn");
btn.onclick=btnClick;
btn.addEventListener('click',function(){
alert("btn clicked");
});
btn.addEventListener('mouseover',function(){
console.log('mouse over is activated');
});
btn.addEventListener('mouseout',function(){
console.log('mouse out is activated');
});
let person={}
console.log(person);
//*****CLASS AND OBJECT*****
class Shape {
constructor(){
this.color = 'red';
}
getColor(){
return this.color;
}
}
class Rectangle extends Shape{
}
let rect = new Rectangle();
console.log(rect.getColor());
console.log(rect);
//*****CONSTRUCTOR FUNCTION*****
function Cons(name,age) {
this.name=name;
this.age=age;
}
var c = new Cons('Priya',22);
console.log(c);
*/
</script>
</body>
</html>