<style>
div.tabs {
background: #333;
padding: 1em;
}
div.container {
margin: auto;
width: 90%;
margin-bottom: 10px;
}
ul.tabNavigation {
list-style: none;
margin: 0;
padding: 0;
}
ul.tabNavigation li {
display: inline;
}
ul.tabNavigation li a {
padding: 3px 9px;
background-color: #666;
color: #000;
text-decoration: none;
}
ul.tabNavigation li a.selected,
ul.tabNavigation li a.selected:hover {
background: #FFF;
color: #000;
}
ul.tabNavigation li a:hover {
background: #ccc;
color: #000;
}
ul.tabNavigation li a:focus {
outline: 0;
}
div.tabs div {
padding: 5px;
margin-top: 3px;
border: 1px solid #FFF;
background: #FFF;
}
div.tabs div h2 {
margin-top: 0;
}
</style>
<div class="tabs">
<!-- Это сами вкладки -->
<ul class="tabNavigation" id="list">
<li><input type="button" value="←" id="butt1" />
<li><a class="" href="#first">Первый</a></li>
<li><a class="" href="#second">Второй</a></li>
<li><a class="" href="#third">Третий</a></li>
<li><input type="button" value="→" id="butt2" />
</ul>
<!-- Это контейнеры содержимого -->
<div id="div">
<div id="first">
<h2>Первый</h2>
</div>
<div id="second" style="display: none">
<h2>Второй</h2>
</div>
<div id="third" style="display: none">
<h2>Третий</h2>
</div>
</div>
<script>
window.onload = function () {
var list = document.getElementById('list');
var cur = document.getElementById('div').children[0];
function sh(cur, next) {
cur.style.display = 'none';
next.style.display = 'block';
}
list.onclick = function (e) {
e = e || event;
var target = e.target || e.srcElement;
var n = this.children.length;
var elem;
if (target == this.children[0].children[0]) {
if (cur.previousSibling.previousSibling) {//previousElementSibling
elem = cur.previousSibling.previousSibling;
sh(cur, elem);
cur = elem;
}
} else
if (target == this.children[n-1].children[0]) {
if (cur.nextSibling.nextSibling) {//nextElementSibling
elem = cur.nextSibling.nextSibling;
sh(cur, elem);
cur = elem;
}
} else
if (target.parentNode.parentNode == this) {
elem = document.getElementById(target.getAttribute('href').replace('#', ''));
sh(cur, elem);
cur = elem;
}
}
}
</script>