简体   繁体   中英

Changing background-color when div fadeIn

I am trying to change background-color when a div fade-in but the below code did not worked.

Instead it only fadeOut and nothing shows when I tried to click to fadeIn.

$('#divbutton').toggle(function(){
        $('#divbutton').text('Show');
        $('#message').fadeOut('1000');

   } , 
   function(){
       $('#divbutton').text('Hide');
       $('#message').$this.css('background-color', 'red').fadeIn('1000');

   }
);

Your syntax to the following line is incorrect. change:

$('#message').$this.css('background-color', 'red').fadeIn('1000');

to:

$('#message').css('background-color', 'red').fadeIn('1000');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM