i don't understand the ".each" part....  jQuery is already going to do
that

$('#nav > li').bind('mouseenter mouseleave', function() { $
(this).toggleClass('hover'); });

*should* be equiv, although i must say that's untested

and how about *zero* jQuery code and just using CSS's ":hover" pseudo?

http://www.w3schools.com/css/pr_pseudo_hover.asp


On Jan 13, 1:22 pm, seasoup <seas...@gmail.com> wrote:
> Is this it, or do you have something shorter?
>
> $('#nav > li').each( function () {
>         var $this = $(this);
>         $this.bind('mouseenter mouseleave', function()
> { $this.toggleClass('hover') });
>
> });
>
> I thought hover would work, but it only does the mouseenter with one
> parameter, instead of doing the same function for both enter and
> leave.
>
> $('#nav > li').each( function () {
>         var $this = $(this);
>         $this.hover(function() { $this.toggleClass('hover') });   //
> only mouseover
>
> });
>
> which could be abstracted to a hoverClass plugin
> $('#nav > li').hoverClass('hover');

Reply via email to