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 adult object, capture in variable object
  • use base 10 parseint function (always this)
  • cache .car_ul , respective li
  • use .not() method leverage caching of .car_ul
  • use .first() , .last() methods leverage caching of li
  • 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

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -