Jump to content

Can't Animate Background Image Using jQuery Library


Eyad Syria-lover

Recommended Posts

This Code Isn't Working:

 

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

 

<script>

$(document).ready(function(){

$("#area").animate({

backgroundImage:"url('image2.png')"

},2000);

});

</script>

 

<style>

#area

{

width:100%;

height:600px;

background-image:url("image2.png");

}

</style>

 

<div id="area"></div>

Link to comment
Share on other sites

I'm not sure what you expected it to do. You can't animate background images, you can only animate properties with numbers as values. (colors are also numbers)

 

 

Here's a list of properties that can be animated: http://www.w3schools.com/cssref/css_animatable.asp

jQuery is capable of animating a few Javascript properties which aren't on that list, such as scrollTop.

Edited by Ingolme
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...