mercredi 24 février 2021

Use jQuery code IF ELSE into element Find() if I use different class

How Can I change background color in /li/ element creating using jQuery? I want find /li/ with class (odd, even - this class add already in PHP ) and using animate() change to background for odd even element from startColor to endColor.

Thanks for answers :) .


(function($) {

var      list = $('#item-list'),
    animation = {
                  startColor: '#00bc8c',
                  delay: 200
                 },
          odd = list.find('li.odd'),
      newItem = $(html).find('#item-list');

 newItem.appendTo( list )
        .css({ backgroundColor: animation.startColor })
        .delay( animation.delay )
        .find(function(){  
                          if( !odd )
                          { animate({backgroundColor:  '#4e5d6c' }) }
                          else
                          { animate({backgroundColor:  '#3b9ae1' }) }
                       });
}(jQuery));

Aucun commentaire:

Enregistrer un commentaire