Fade the background-color of a span tag with JQuery

前端 未结 12 656
北恋
北恋 2020-12-09 16:20

I\'m trying to fade the background-color of a span tag using JQuery to emphasize when a change has occured. I was thinking the code would be someting like the following ins

12条回答
  •  無奈伤痛
    2020-12-09 16:41

    I didnt want to use a plugin So to fade a background in and out i included this for the div class thats to have its background faded

    .div-to-fade {
        -webkit-transition:background 1s;
        -moz-transition:background 1s;
        -o-transition:background 1s;
        transition:background 1s
    }
    

    the jquery which is in a button click

    $('.div-to-fade').css('background', 'rgb(70, 70, 70)');
    setTimeout(function(){$('.div-to-fade').css('background', '')}, 1000);
    

    This will color the background light grey and then fade back to the orig color I hope this contributes

提交回复
热议问题