jQuery .live mouseover erroring out -
i have unordered list (ul) i'm trying bind mouseover/mouseenter event on list item (li) children using .live() keep getting following javascript error:
error: uncaught exception: syntax error, unrecognized expression: )
here's code:
<ul id="menu"> <li>option 1 <ul> <li>sub-option a</li> <li>sub-option b</li> <li>sub-option c</li> <li>sub-option d</li> <li>sub-option e</li> </ul> </li> <li>option 2</li> <li>option 3</li> </ul>
the jquery code:
$("#menu").children().live("mouseover", function(){ // });
the crazy thing when change .mouseover() function works fine except issue flickering associated .mouseover() .live("mouseover", ...) fixes.
am doing wrong here? jquery bug? have insight issue?
from the docs:
dom traversal methods not supported finding elements send .live(). rather, .live() method should called directly after selector
which means can't $("#menu").children().live(...)
since .children()
dom traversal method.
although syntax error suggests code problematic, i.e. not formatted. such problem lies in code didn't post.
finally, suggest use delegate
:
$('#menu').delegate('li', 'mouseover', function(){ ... });
although should doing static bind unless need live
or delegate
functionality. it's not supposed fix random flickering issues - you're supposed debug yourself.
Comments
Post a Comment