jquery background from image to color and back again -


I have an html page in which jquery is loaded. There is no CSS at this time.

The background image is set to:

  & lt; Body background = "image1.gif" & gt;   

I'm trying to convert it to a color (say black) and again by returning the image using onclick.

I have been able to set up Dives and all colors are used to change the color:

  jQuery ('body'). CSS ('background color', 'black');   

On any other page, but it does not work here because I want to color the image again and again.

Then, I can use CSS to change the background and change the square instead:

P>

HTML:

  & lt; Body class = "image" & gt;   

CSS:

  body.image {background-image: url ('image.gif'); } Body.colour {background color: black; }   

For more scripting:

  $ ('body'). AddClass ('color'). RemoveClass ('image');   

and back again:

  $ ('body'). AddClass ('image'). RemoveClass ('color');    

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -