Guys I have a problem in div selection. I have to use lot of dives in my code. but at the same time I have back button at header so i want that back button pressed then I move to back div.
here is my java script code.
<script type="text/javascript">
function toggle_visibility(id) {
var e = document.getElementById(id);
if (e.style.display == 'block') e.style.display = 'none';
else e.style.display = 'block';
hideAllBut(id);
}
function hideAllBut(id) {
var lists = document.querySelectorAll('.list');
for (var i = lists.length; i--;) {
if (lists[i].id != id) {
lists[i].style.display = 'none';
}
}
}
</script>
And Here is my html code example.
<style>
body{
}
#list1 {background-color: coral;}
#list2 {background-color: #45cd2a;}
#list3 {background-color: #ab4d2a;}
</style>
<form action="????" >
<button> Go to back div</button>
</form>
<a href="#" onclick="toggle_visibility('list1');">List One</a>
<a href="#" onclick="toggle_visibility('list2');">List Two</a>
<input type="button" value="List Four" onclick="toggle_visibility('list3');">
</input>
<div id="list1" class="list" style="display:none;">
<ul>
<li>Item One</li>
<li>Item Two</li>
<li>Item Three</li>
</ul>
</div>
<div id="list2" class="list" style="display:none;">
<ul>
<li>Item One</li>
<li>Item Two</li>
<li>Item Three</li>
</ul>
</div>
<div id="list3" class="list" style="display:none;">
<ul>
<li>Item One</li>
<li>Item Two</li>
<li>Item Three</li>
</ul>
</div>
</body>
</html>
This code works fine but i don't know how to implement a back button to go back div..?? kindly help me.