-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfm.html
122 lines (116 loc) · 2.48 KB
/
fm.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
122
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>expl</title>
<script language="javascript">
var nowid=0;
var maxid=5;
var next;
var prev;
function fn1()
{
nowid++;
if(nowid>maxid){
nowid=1;
}
if(nowid<1){
nowid=maxid;
}
prev=nowid-1;
next=nowid+1;
if(next>maxid){
next=1;
}
if(prev<1){
prev=maxid;
}
document.getElementById('txt').innerHTML=document.getElementById('id_'+nowid).title;
document.getElementById('prev').innerHTML=document.getElementById('id_'+prev).title;
document.getElementById('next').innerHTML=document.getElementById('id_'+next).title;
}
function fn2()
{
nowid--;
if(nowid>maxid){
nowid=1;
}
if(nowid<1){
nowid=maxid;
}
prev=nowid-1;
next=nowid+2;
if(next>maxid){
next=1;
}
if(prev<1){
prev=maxid;
}
document.getElementById('txt').innerHTML=document.getElementById('id_'+nowid).title;
document.getElementById('prev').innerHTML=document.getElementById('id_'+prev).title;
document.getElementById('next').innerHTML=document.getElementById('id_'+next).title;
}
window.onload=(function(){fn1();});
</script>
</head>
<body>
<div>
<a title="这是1" id="id_1">这是1</a><br>
<a title="这是2" id="id_2">这是2</a><br>
<a title="这是3" id="id_3">这是3</a><br>
<a title="这是4" id="id_4">这是4</a><br>
<a title="这是5" id="id_5">这是5</a><br>
</div>
<br><br>
<br>
<style>
.go{
padding:5px;
border:solid 1px;
}
</style>
<span id="ptxt" class='go'></span>
<span id="txt" class='go'>现</span>
<span id="ntxt" class='go'></span>
<br>
<br>
<input value="后" id="prev" type='button' />
<input value="前" id="next" type='button' />
<script type="text/javascript" >
var data=document.getElementsByTagName("a"),
index=0,
prevStore;
var $=function(id){
return document.getElementById(id);
}
function show(){
$("txt").innerHTML=data[index].innerHTML;
$("ntxt").innerHTML=data[(index+1)%data.length].innerHTML;
if(prevStore>-1){
$("ptxt").innerHTML=data[prevStore].innerHTML;
}
else{
$("ptxt").innerHTML="";
}
}
function prev(){
if(prevStore==-1){
return ;
}
index=prevStore;
prevStore=-1;
//$("prev").style.display="none";
show();
}
function next(){
prevStore=index;
index++;
index%=data.length;
//$("prev").style.display="";
show();
}
$("prev").onclick=prev;
$("next").onclick=next;
</script>
</body>
</html>