This repository has been archived by the owner on Jul 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
121 lines (101 loc) · 2.72 KB
/
index.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
<!--<div class="outer">
<div class="inner">
<div class="log">
<p>
Système de coordonnées Offset : <span id="offsetX">0</span>,
<span id="offsetY">0</span>
</p>
<p>
Système de coordonnées Client : <span id="clientX">0</span>,
<span id="clientY">0</span>
</p>
<p>
Système de coordonnées Page : <span id="pageX">0</span>,
<span id="pageY">0</span>
</p>
<p>
Système de coordonnées Écran : <span id="screenX">0</span>,
<span id="screenY">0</span>
</p>
</div>
</div>
<div class="log">
<p>sakut a tous c'erst david la farge pokémon</p>
</div>
</div>-->
<div>
<h2>Les événéments liés à la souris</h2>
<p class="afficher">Dans cette leçon, nous allons découvrir les méthodes
jQuery nous permettant de gérer les événements les plus communs liés à la
souris (clic, passage de la souris sur un élément, etc.). </p>
</div>
<script>
let inner = document.querySelector(".inner");
let log = document.querySelector(".log");
function setCoords(e, type) {
let idX = type + "X";
let idY = type + "Y";
document.getElementById(idX).innerText = e[idX];
document.getElementById(idY).innerText = e[idY];
}
function update(e) {
setCoords(e, "offset");
setCoords(e, "client");
setCoords(e, "page");
setCoords(e, "screen");
}
inner.addEventListener("mouseenter", update, false);
inner.addEventListener("mousemove", update, false);
inner.addEventListener("mouseleave", update, false);
//JQUERY
$(document).ready(function(){
//Lors d'un clic sur le div...
$("div").click(function(){
//...On inverse les classes de p
$("p").toggleClass("afficher cacher");
//Les éléments avec .afficher seront visibles
$(".afficher").show();
//Les éléments avec .cacher seront cachés
$(".cacher").hide();
});
//Lors d'un double clic sur le div...
$("div").dblclick(function(){
//...On lui applique une couleur de fond bleu clair
$(this).css("background-color", "lightBlue");
});
});
</script>
<style>
div{
border: 1px solid #555;
border-radius: 10px;
}
h2, p{
margin: 0px;
padding: 5px;
}
.outer {
width: 1000px;
height: 200px;
background-color: red;
}
.inner {
position: relative;
width: 500px;
height: 150px;
top: 25px;
left: 100px;
background-color: blue;
color: white;
cursor: crosshair;
user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-webkit-user-select: none;
}
.log {
position: relative;
width: 100%;
text-align: center;
}
</style>