Greetings,
Followed the above, however I'm unable to get the end result. The li item which is currently selected has no background. On click i have anchor placed within the same html page (page url doesn't change)
I want to create something like this image
example image
Thanks for you kind help.
Regards
enter code here
The HTML
<link rel="stylesheet" type="text/css" href="screen.css"/>
<script type="text/javascript">
$(document).ready(function() {
$(".buttons a").click(function() {
$(".buttons a").removeClass("selected");
$(this).addClass("selected");
});
});
</script>
<div id="side-bar">
<ul class="buttons">
<li><a class="button" href="#tier1">Link1</a></li>
<li><a class="button" href="#tier2">Link2</a></li>
<li><a class="button" href="#tier3">Link3</a></li>
<li><a class="button" href="#tier4">Link4</a></li>
</ul>
</div>
<div id="content">
<a name="tier1" /><h4>Tier 1</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id nibh nec augue condimentum feugiat vitae in arcu. Quisque condimentum, est sit amet dictum pulvinar, dui nulla laoreet dui, ut consequat est massa vel massa. Pellentesque ultricies pharetra convallis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. </p>
<a name="tier2" /><h4>Tier 2</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id nibh nec augue condimentum feugiat vitae in arcu. Quisque condimentum, est sit amet dictum pulvinar, dui nulla laoreet dui, ut consequat est massa vel massa. Pellentesque ultricies pharetra convallis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Praesent tristique diam dapibus ante pulvinar ut sagittis tellus ornare.</p><p>Lorem ipsum dolor sit amet, </p>
<a name="tier3" /><h4>Tier 3</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id nibh nec augue condimentum feugiat vitae in arcu. Quisque condimentum, est sit amet dictum pulvinar, dui nulla laoreet dui, ut consequat est massa vel massa. Pellentesque ultricies pharetra convallis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Praesent tristique diam dapibus ante pulvinar ut sagittis tellus ornare.</p><p>Lorem ipsum dolor sit amet, </p>
<a name="tier4" /><h4>Tier 4</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id nibh nec augue condimentum feugiat vitae in arcu. Quisque condimentum, est sit amet dictum pulvinar, dui nulla laoreet dui, ut consequat est massa vel massa. Pellentesque ultricies pharetra convallis. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Praesent tristique diam dapibus</p>
</div>
THE CSS
#side-bar{
position:relative;
top:0;
left:0;
float:left;
width:200px;
}
#content{
position:relative;
top:0;
left:0;
float:left;
width:500px;
margin:0px 20px;
}
ul.buttons{
list-style:none;
background: #ff0;
}
.button {
display:block;
border-bottom:1px dotted #ccc;
padding:10px;
}
a:link, a:visited{
color:#000;
}
a.selected:link{
color:#000;
text-decoration: none;
background:#ff0000;
}
a:hover{
text-decoration: none;
}