Animate background color like a progress bar in jQuery

前端 未结 11 2188
南笙
南笙 2021-02-05 23:11

I have a div which has some text content( eg: My Name ) and the div is in RED background colour

11条回答
  •  暖寄归人
    2021-02-05 23:56

    1. JavaScript variable names can't have dashes, it should be backgroundColor.
    2. You have 'red', so it will not change anything. Change the string to 'blue'.
    $("button").click(function(){ 
          $('#myDivId').animate({ backgroundColor: 'blue' }, 10000);
    });
    

提交回复
热议问题