-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtask11.html
More file actions
54 lines (50 loc) · 1.09 KB
/
task11.html
File metadata and controls
54 lines (50 loc) · 1.09 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!Doctype html>
<html>
<head>
<style>
li {
border: 1px solid #999;
height: 2em;
width: 2em;
}
li.selected {
background: green;
}
ul {
list-style: none outside;
padding: 0;
}
</style>
<script src="jquery-3.1.1.min.js"></script>
<script>
$(function () { // same as (document).ready(function () {..})
var slides = $("#slides li"); // find the slides once
// common next/prev function
function changeSlide(direction) {
var target,
current = slides.filter(".selected"); // find the current slide
target = current[direction](); // call either .next() or .prev()
if(target.length) { // if there is a next/prev slide...
current.removeClass();
target.addClass("selected");
}
}
$(".next").on("click", function () { changeSlide('next') });
$(".prev").on("click", function () { changeSlide('prev') });
});
</script>
<title>
</title>
</head>
<body>
<ul id="slides">
<li class="selected"></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
<button class="prev">Prev</button>
<button class="next">Next</button>
</body>
</html>