One issue is that the CSS is missing for the #magic-line
because there is a selector named #MagicLine
in the CSS file.
Another problem is that the .hover()
selector is not correct. It should bind the hover event to the child <a>
tags of the menu items
$("#example-one li a").hover(function() {
, but it is currently bound to the magic-line instead
$("#navMagicLine li a").hover(function() {
. This causes the width calculation to be incorrect, resulting in the magic line being longer than expected.
Fixing these issues may resolve the menu problem, but I would suggest reviewing example code or creating your own demo to troubleshoot. Creating a demo in jsFiddle or another site often helps clarify the issue :-)
Edit:
Furthermore, your CSS still does not match the demo. The list items should have display:inline-block
, otherwise jQuery cannot calculate the .width()
. Inline elements do not have width (or height).
The CSS should be:
#navMagicLine li {
display: inline-block;
}
The .hover()
should be on the <a>
of your menu, not on the dynamic line. It should be:
$("#navMagicLine li a").hover(function() {
// function body
})