css - Using :not selector with jquery variable -
after looking @ jquery selector variable in selector , few other posts, i'm not finding answer question, makes me think maybe i'm maybe going wrong.
i have .car_ul li element being passed in 'el',
i'm trying operate on $('.car_ul:not(:animated)') using $(':not(:animated)',adult) - wondering how can that?
slideleft: function(el) { var adult = el.parent.attr('class') var itemwidth = el.outerwidth() + 10 var leftindent = parseint(adult.css('left')) + itemwidth $('.car_ul:not(:animated)').animate({'left' : leftindent}, 500, function() { $('.car_ul li:first').before($('.car_ul li:last')) $(adult).css({'left':'-160px'}) }) },
since asked possible optimization points:
slideleft:function($el){ var $adult = $('.'+$el.get(0).parentnode.classname), itemwidth = $el.outerwidth() + 10, leftindent = parseint($adult.css('left'),10), $menu = $('.car_ul'), $li = $menu.find('li'); $menu.not(':animated').animate({left:leftindent},500,function(){ $li.first().before($li.last()); $adult.css({left:-160}); }); }, - since need
adultobject, capture in variable object - use base 10
parseintfunction (always this) - cache
.car_ul, respectiveli - use
.not()method leverage caching of.car_ul - use
.first(),.last()methods leverage caching ofli - use dom names , numeric values rather string values css assignments
i renamed el variable $el ... more stylistic, considered best practice call out jquery objects vs dom elements naming convention.
hope helps!
Comments
Post a Comment