Change text (html) with .animate

后端 未结 7 2105
灰色年华
灰色年华 2020-12-23 20:04

I am trying to animate the html part of a tag ( This Text! ) using jQuery\'s Animate function, like so:

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-23 20:22

    For fadeOut => change text => fadeIn effect We need to animate the wrapper of texts we would like change.

    Example below:

    HTML

    1400
    sklepów

    Some text

    Lorem ipsum description
    2018

    JQuery JS

    $(document).ready(function(){
    
      $('.ch-timeline .el').on('click', function(){
    
        $('.ch-timeline .el').removeClass('current');
        $(this).addClass('current');
    
        var ilosc = $(this).data('ilosc');
        var y = $(this).data('y');
        var title = $(this).find('.title').html();
        var desc = $(this).find('desc').html();
    
        $('.timeline-yeardata .anime').fadeOut(400, function(){
          $('#ilosc-sklepow').html(ilosc);
          $('#current-year').html(y);
          $('.timeline-yeardata .title').html(title);
          $('.timeline-yeardata .desc').html(desc);
          $(this).fadeIn(300);
        })
    
      });
    
    });
    

    Hope this will help someone.

提交回复
热议问题