I am trying to move the .icon element to the right and animate it based on its position().left value.
Unfortunately, my code is not working as expected and I can't figure out why. It seems like such a simple task!
<script>
$("li.menu-item").hover(function(){
var pos = $(this).position().left;
$(".icon").animate({left : pos+'px'}, 1500 );
});
</script>
</head>
<body>
<div id="menu-wrapper">
<ul id="main-nav">
<li class="menu-item"><a href="">Blog</a></li>
<li class="menu-item"><a href="">Sponsored</a></li>
<li class="menu-item"><a href="">Facebook</a></li>
<li class="menu-item"><a href="">Twitter</a></li>
<li class="menu-item"><a href="">About</a></li>
<li class="menu-item"><a href="">Contact</a></li>
</ul;
<div class="icon">move please</div>
</div><!-- //END menu-wrapper -->
</body>
CSS:
#menu-wrapper { position: fixed; bottom: 50px; margin: 0 auto; text-align:center;}
.icon {
width: 9px;
height: 9px;
background: url(../images/plus-menu.png) no-repeat 0 0;
position: absolute;
left: -5px;
bottom: -4px;
}
#main-nav { line-height: 1.0; float: left; margin-bottom: 1em; }
#main-nav{list-style: none;}
#main-nav li a {
display: block;
position: relative;
text-decoration: none;
margin-right: 20px;
color: #b2b2b2;
line-height: 19px;
padding-bottom: 17px;
}
#main-nav li { float: left; position: relative; }
#main-nav li a:hover, #main-nav li a:active { color: #404040; }
Any assistance would be greatly appreciated.
Thank you