I have some jquery that pretty much just runs a small drop-line navigation. Each tab size differs, so i used the same jquery line 5 times to make it look and function the way i wanted it to. I'm sure there is a way to condense it but im not quite a pro. Can anybody help me out a bit? The jquery is below, and here is the site for reference: http://solocreativegroup.com/ed_spa/index.php. Thanks!
here's the code that runs my drop-line nav.
$(document).ready(function() {
$("ul#topnav li.home").hover(function() { //Hover over event on list item
$(this).css({ 'background' : 'url(images/tab_hobt.png) no-repeat top left'}); //Add background color + image on hovered list item
$(this).find("span").show(); //Show the subnav
}, function() { //on hover out...
$(this).css({ 'background' : 'none'}); //Ditch the background
$(this).find("span").hide(); //Hide the subnav
});
$("ul#topnav li.about").hover(function() {
$(this).css({ 'background' : 'url(images/tab_hobt.png) no-repeat top left'});
$(this).find("span").show();
$('.services a').css({'color':'#ffffff'});
}, function() {
$(this).css({ 'background' : 'none'});
$(this).find("span").hide();
$('.services a').css({'color':'#921d49'});
});
$("ul#topnav li.services").hover(function() {
$(this).css({ 'background' : 'url(images/tab_services.png) no-repeat top left'});
$(this).find("span").show();
$('.services a').css({'color':'#ffffff'});
}, function() {
$(this).css({ 'background' : 'none'});
$(this).find("span").hide();
$('.services a').css({'color':'#921d49'});
});
$("ul#topnav li.testimonial").hover(function() {
$(this).css({ 'background' : 'url(images/tab_testimonials.png) no-repeat top left'});
$(this).find("span").show();
}, function() {
$(this).css({ 'background' : 'none'});
$(this).find("span").hide();
});
$("ul#topnav li.contact").hover(function() {
$(this).css({ 'background' : 'url(images/tab_contact.png) no-repeat top left'});
$(this).find("span").show();
}, function() {
$(this).css({ 'background' : 'none'});
$(this).find("span").hide();
});
HTML:
<ul id="topnav">
<li class="home" style="width:80px;"><a href="index.php">HOME</a></li>
<li class="about" style="width:80px;"><a href="about.php">ABOUT</a>
<span>
<a href="products.php">PRODUCTS</a>
</span>
</li>
<li class="services" style="width:111px;">
<a href="services.php">SERVICES</a>
<span>
<a href="#">FACIALS</a>
<a href="#">AGE MANAGEMENT</a>
<a href="#">MICRODERMABRASION</a>
<a href="skin-resurfacing.php">SKIN RESURFACING</a>
<a href="add-it-on.php">ADD IT ON</a>
<a href="#">WAXING</a>
</span>
</li>
<li class="testimonial" style="width:141px;"><a href="testimonials.php">TESTIMONIALS</a></li>
<li class="contact" style="width:94px;"><a href="contact.php">CONTACT</a></li>
</ul>