While $("li a").hover(function(){ $(this).addClass("move"); }, function() { $(this).removeClass("move"); });
works well in theory, I've found that $("li a").hover(function(){ $("li a").removeClass("move"); $(this).addClass("move"); }, function() { $(this).removeClass("move"); }); is necessary in practice. Assuming of course that you can't use the CSS solution which is obviously preferable. _jason On May 15, 8:09 am, "benoit v." <benv...@gmail.com> wrote: > what about that ? > > $("li a").hover(function(){ > $(this).toggleClass("move"); > }); > > On May 15, 4:42 pm, Jthomas <wjthom...@yahoo.com> wrote: > > > Hi Calvin, > > I think what you're looking for is something like this, as James said. > > > $("li a").hover(function(){ > > $(this).addClass("move"); > > }, function() { > > $(this).removeClass("move"); > > }); > > > Of course, include document ready function. > > -Jon Thomas > > > On May 14, 8:35 pm, Calvin <cstephe...@gmail.com> wrote: > > > > Hi, > > > > I was able to get this script to work and was wondering if there was > > > a better/proper/more efficient way of writing it. Here is the script: > > > > $(document).ready(function() { > > > $('li.a').hover(function() { > > > $(this).addClass('move'); > > > }); > > > $('li.a').mouseLeave(function() { > > > $(this).removeClass('move'); > > > > )}; > > > )}; > > > > Thanks for your time, > > > > Calvin Stephens