Click here to Skip to main content
15,921,028 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
.HTML
===========

XML
<div id="left_float_menu"  align="left">
               <ul id="nav_bar">
       <li id="nav_bar1"><span>Home</span></li>
       <li ><span>About</span></li>
       <li ><span>Contact</span></li>
       <li><span>FAQ</span></li>
       <li><span>News</span></li>
   </ul>

=====================

Jquery

=========
C#
jQuery(document).ready(function(){
$("#nav_bar1 li").hover(
function(){
$(this).parent().parent().animate({ width: "140px" }, {queue:false, duration:"normal"} );
$(this).parent().parent().find("span").animate({opacity: "show"}, "fast");
},
function(){
$(this).parent().parent().animate({ width: "30px" }, {queue:false, duration:"normal"} );
$(this).parent().parent().find("span").animate({opacity: "hide"}, "fast");
});
});


=============

Hi here i am trying to move my first Vertical bar ( HOME) to move a bit left when hovered and back to the same position when not hovered.

Not working!!!

can someone put some light into my Jquery code.
Posted

1 solution

Some things you need to correct:
1. Modify "Left" property not "Width". Width will expand/contract it not move it.
2. Make the div as relative: style="position:relative".

Some things you might want to change:
1. Instead of writing "$(this).parent().parent()" try "$(this).parents('div')".

Hope these points will help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900