Requirements
jquery.js : the jQuery library
jquery.corner.js : jQuery corner plugin
The HTML
Yes, its an unordered list. The first anchor element has a class attribute selected.
- <div id="nav">
- <ul>
- <li><a href="#" class="selected">Home</a></li>
- <li><a href="#">Blog</a></li>
- <li><a href="#">About</a></li>
- <li><a href="#">Contact</a></li>
- </ul>
- </div>
The CSS
If you have already read my post on horizontal navigation bar, I dont think the css below needs much explanation. But notice the css for hover effect.
- #nav ul {
- margin: 0px;
- padding: 0px;
- list-style: none;
- }
- #nav ul li {
- background-color: #990000;
- }
- #nav ul li,
- #nav ul li a {
- float: left;
- display: block;
- }
- #nav ul li a {
- margin: 15px;
- padding: 5px;
- font-size: 24px;
- color: #fff;
- text-decoration: none;
- }
We want the same effect for selected and hovered anchor elements
- #nav ul li a:hover,
- #nav ul li a.selected {
- background-color: #fff;
- color: #272727;
- }
The JavaScript (jQuery)
There is not much javascript to it at all. Just add the two javascript files mentioned above, and add three more lines of code.
- <script type="text/javascript" src="jquery.pack.js"></script>
- <script type="text/javascript" src="jquery.corner.js"></script>
- <script type="text/javascript">
- $(document).ready(function() {
- $("#nav ul li a").corner();
- });
- </script>
Done! You really dont need to do anything more. Have fun.













