1.

Consider the following code that exists in following HTML with the CSS:

Answer»
<div id="expand"></div>

<style>
div#expand{
width: 50px;
height: 50px;
background-color: gray;
}
</style> Write jQuery code to animate the #expand div, expanding it from 50 * 50 pixels to 300 * 300 pixels within five seconds.

We can do this by using the animate() function. We first need to have access to the div element which has id value of expand and then apply animate function on the element as follows:

$("#expand").animate(
{
width: "300px",
height: "300px",
},
5000
);


Discussion

No Comment Found