-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.html
39 lines (37 loc) · 962 Bytes
/
demo.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="../jquery-1.11.3.min.js"></script>
</head>
<body>
<style type="text/css">
.selected{background-color: #f92873
}
</style>
<button id="chooseNext">选择下一个</button>
<div id="liList">
<li class="selected">1111111</li>
<li>2222222</li>
<li>3333333</li>
<li>4444444</li>
<li>5555555</li>
<li>6666666</li>
<li>7777777</li>
</div>
<script type="text/javascript">
$(function(){
var length = $("#liList").children("li").length - 1;
$("#chooseNext").on("click",function(){
var sIndex = $("#liList").children("li.selected").index();
if(sIndex == length){
sIndex = -1;
}
$("#liList").children().removeClass("selected");
$("#liList").children("li:eq(" + (sIndex + 1) + " )").addClass("selected");
})
})
</script>
</body>
</html>