-
Notifications
You must be signed in to change notification settings - Fork 1
/
dois.html
92 lines (84 loc) · 2.79 KB
/
dois.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
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="utf-8" />
<title>tutorial DIY slideshow</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
//identifica o slideshow
$slideshow = $("#slideshow");
//inicialmente esconde os slides
$slideshow.find("li.slide").hide();
//encontra o prmeiro slide e ativa-o
$slideativo = $slideshow.find("li.slide").first().addClass('slideatual').show();
//ao clicar mostra o proximo slide
$('#slideproximo').click(function(){
//esconde o slide atual
$slideativo.animate({
"width": "toggle", "opacity": "toggle"
}, "slow", function() {// callback
//procura o proximo
$slideativo = $slideshow.find("li.slideatual").next();
if(!$slideativo.size()) $slideativo = $slideshow.find("li.slide").first();//volta ao primeiro
//remove o marcador do slide anterior
$slideshow.find("li.slideatual").removeClass("slideatual");
//coloca o marcador e mostra
$slideativo.addClass("slideatual").animate({
"width": "toggle", "opacity": "toggle"
}, "slow");
});
});
//ao clicar mostra o slide anterior
$('#slideanterior').click(function(){
$slideativo.animate({
"width": "toggle", "opacity": "toggle"
}, "slow", function() {// callback
$slideativo = $slideshow.find("li.slideatual").prev();
if(!$slideativo.size()) $slideativo = $slideshow.find("li.slide").last();//volta ao ultimo
$slideshow.find("li.slideatual").removeClass("slideatual");
$slideativo.addClass("slideatual").animate({
"width": "toggle", "opacity": "toggle"
}, "slow");
});
});
});
</script>
<style type="text/css">
#slides{
list-style-type: none;
}
.slide{
width: 200px;
height: 200px;
border: 1px solid #000;
}
</style>
</head>
<body>
<div id="slideshow" >
<p>
<button id="slideanterior" class="slideshow-button" >anterior </button>
<button id="slideproximo" class="slideshow-button" > próximo</button>
</p>
<ul id="slides">
<li class="slide">
1
</li>
<li class="slide">
2
</li>
<li class="slide">
3
</li>
<li class="slide">
4
</li>
<li class="slide">
5
</li>
</ul>
</div><!-- fim slideshow -->
</body>
</html>