-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRemember_Active_Tab.html
49 lines (46 loc) · 1.23 KB
/
Remember_Active_Tab.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>remember which tab was active after refresh</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script>
$(function() {
var index = 'key';
var dataStore = window.sessionStorage;
try {
var oldIndex = dataStore.getItem(index);
} catch(e) {
var oldIndex = 0;
}
$('#tabs').tabs({
active : oldIndex,
activate : function( event, ui ){
var newIndex = ui.newTab.parent().children().index(ui.newTab);
dataStore.setItem( index, newIndex )
}
});
});
</script>
</head>
<body>
<div id="tabs">
<ul>
<li><a href="#tabs-1">Lalit1</a></li>
<li><a href="#tabs-2">Lalit2</a></li>
<li><a href="#tabs-3">Lalit13</a></li>
</ul>
<div id="tabs-1">
<p> Tab 1</p>
</div>
<div id="tabs-2">
<p> Tab 2</p>
</div>
<div id="tabs-3">
<p> Tab 3</p>
</div>
</div>
</body>
</html>