-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEventListener.html
More file actions
31 lines (30 loc) · 1.16 KB
/
EventListener.html
File metadata and controls
31 lines (30 loc) · 1.16 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
29
30
31
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title> jQuery exercises </title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
function incSize(event) {
var width = Number(event.target.style.width.substring(0, event.target.style.width.length - 2));
event.target.style.width = (width + 5) + "px";
$("<p>Mouse clicked on coordinates: x - " + event.screenX + ", y - "
+ event.screenY + ".</p>").insertAfter("div:last");
}
setTimeout(function(){
$('p:first-child').remove();
}, 2000);
$(document).ready(function () {
$("div").bind("click", incSize);
$(document).on("click", "p", function(){
event.target.remove();
});
});
</script>
</head>
<body>
<div style="height: 80px; width: 80px; background-color: blue"></div>
<div style="height: 80px; width: 80px; background-color: red"></div>
<div style="height: 80px; width: 80px; background-color: green"></div>
</body>
</html>