Jump to content
Killersites Forums

jQuery change background only


williamrouse
 Share

Recommended Posts

I have been working on this for a while and I guess a while longer. The question is how to isolate just the background of a DIV and get it to change color or fade in opacity.

Here is simplified version where I have a DIV with some text. I want to change the background color in a continuous loop while the text remains visible. Below is the code that I wrote, but everything fades not just the background. How can I correct this?

 

//continual fade
function lowerLeftFadeIn() {
$('#lowerLeft').fadeOut(10000).css('background-color' , '#ffff99'), lowerLeftFadeOut();
}
function lowerLeftFadeOut() {
$('#lowerLeft').fadeIn(10000).css('background-color' , '#ffff99'), lowerLeftFadeIn();
}
$(document).ready(function(){
lowerLeftFadeIn();
});

Link to comment
Share on other sites

After using the color plugin with this code it worked.

// continual pulse fade  
function lowerLeftFadeIn() {
   $('#lowerLeft').animate({
       backgroundColor: '#ffff99'
   }, 'slow'), lowerLeftFadeOut();
}
function lowerLeftFadeOut() {
   $('#lowerLeft').animate({
       backgroundColor: '#99ffff'
   }, 'slow'), lowerLeftFadeIn();
}

$(document).ready(function(){
   lowerLeftFadeIn();
});

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...