Hover CSS image is not working

For some reason my hover and current state are not working whenever I rollover or click the static image. Can someone please tell me what is wrong with my code? Thank you!

<!--CSS Code-->
<style type='text/css'>
    a.current { 
 background-image: url (images/aa_on.png); 
 background-repeat: no-repeat; }

 #nav a:hover {
background-image: url (images/aa_on.png); 
background-repeat: no-repeat;}
</style>
 
<!--JavaScript Code-->
<script type='text/javascript'>
$(function(){
$('#nav a').click(function(e) {
    e.preventDefault();
    var panel = $(this).attr('href');
    $(this).addClass("current");
    $("a", $(this).parents("li").siblings("li")).removeClass("current");
    // show slide
    $(this).parents("ul").siblings("div").hide();
    $(panel).show();
})
});//]]>  
</script>
 
<!--HTML code-->
<td><ul id="nav" style="list-style-type: none; margin: 0;
 padding: 0;">
<li><a href="#panel2"><img src="images/aa_off.png" border="0" alt="About ASD" style="display:block;"></a></li>
</ul></td>
<div id="panel2" class="panel">This is panel 2</div>
 

Open in new window

bokotieAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bigeven2002Commented:
Hello,
Are you using any specific javascript library with this such as jQuery?  If so, which version?  In your HTML code, you might try moving id="nav" to the li tag instead of the ul tag.
<li id=nav">

Open in new window

0
Chris StanyonWebDevCommented:
Your code is working fine - the problem you have is that your <a> tag contains an image. You try to change the background-image of the <a> tag when it's hovered or current and the background image sits behind the actual image so you don't see it. Remove the <img> from your <a> and you'll see it's working fine.

You can see it working here: http://jsfiddle.net/ChrisStanyon/8tepfpum/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.