On 8/14/07, Eridius <[EMAIL PROTECTED]> wrote: > > > is there anything wring with that code(i don't care about use mouseover() > instead of bind() because i did to test things)? > > It seems to work fine for me, although I would use hover() in order to eliminate the buggy behaviour of mouseout firing sometimes when you hover over the child a element. Also, you don't need to wrap self in a new object, or even have that variable at all. Here is my optimisation:
jQuery.fn.hover_menu = function(offset, speed){ this.children('li').each(function(){ var $$ = $(this); //only create this once and use many times //I'm not familiar with parseFloat, didn't know you could pass in two parameters. Also not sure if you need it here. var current_margin = parseFloat($$.css('margin-left'), 10); var new_margin = parseFloat(current_margin + offset, 10); $$.hover( function(){ $$.animate({paddingLeft: new_margin}, speed);}, function(){ $$.animate({paddingLeft: current_margin}, speed);); ); }); }; Untested. Joel Birch