-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjquery12-eventos.html
53 lines (49 loc) · 1.22 KB
/
jquery12-eventos.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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Eventos</title>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(document).on('ready',function(){
/*
// Ejemplo de uso de eventos en jQuery
// Ejemplo de manejo del evento click
$('a').on('click',function(){
//this es el elemento que disparó el evento
//sería el elemento <a>
console.log($(this).attr('id'));
})
*/
//Otro ejemplo similar
/*
$('a').on('click',function(e){
console.log(e.pageX); //e.screenX)
// probar e.preventDefault
// probar e.type
})
*/
//Ejemplo que muestra cómo vincular y desvincular eventos
// se usan los métodos mouseover y mouseout
// para más información hay que consultar la web de jQuery
/*
var caja1bg;
$('#caja1').mouseover(function(){
caja1bg=$('#caja1').css('background');
$(this).css('background','red');
})
$('#caja1').mouseout(function(){
$(this).css('background',caja1bg);
})
*/
});
</script>
<style>
</style>
</head>
<body>
<a href='http://www.uclm.es' id='evento'>Hola uclm</a>
<a href='http://www.uclm.es' id='evento2'>Hola segundo uclm</a>
<div id="caja1">Hola que tal</div>
</body>
</html>