Click here to Skip to main content
15,896,063 members

1 solution

The problem is the top-level function. Why do you think it should be called, in response to what? It doesn't seem to make any sense. Instead, you should do something like:
JavaScript
$( document ).ready(function() {
    menuItemWrapper = $("#menu a"); // via an id descriptor
    menuItemWrapper.hover(
        function () { // mouse goes in:
            menuItemWrapper.switchClass("style1", "style2", 700);
        },
        function () { // mouse goes out:
            menuItemWrapper.switchClass("style2", "style1", 700);
        }
     );
});
I also simplified handling a bit, replacing two methods .mouseEnter() and .mouseLeave() with on .hover() accepting two handler, on mouse moving in and out.

Please see:
http://learn.jquery.com/about-jquery/how-jquery-works/[^],
http://api.jquery.com/hover/[^],
http://api.jqueryui.com/switchClass/[^].

—SA
 
Share this answer
 
v6
Comments
Dholakiya Ankit 6-Aug-13 0:47am    
5ed
Sergey Alexandrovich Kryukov 6-Aug-13 0:50am    
Thank you, Ankit.
—SA
Dholakiya Ankit 6-Aug-13 0:57am    
no mention

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