jQuery Effects – Animation

Configurare noua (How To)

Situatie

With jQuery, you can create custom animations.

jQuery Animations – The animate() Method

The jQuery animate() method is used to create custom animations.

Syntax:

$(selector).animate({params},speed,callback);

The required params parameter defines the CSS properties to be animated.

The optional speed parameter specifies the duration of the effect. It can take the following values: “slow”, “fast”, or milliseconds.

The optional callback parameter is a function to be executed after the animation completes.

The following example demonstrates a simple use of the animate() method; it moves a <div> element to the right, until it has reached a left property of 250px:

Backup

Example
$(“button”).click(function(){
$(“div”).animate({left: ‘250px’});
}); 
By default, all HTML elements have a static position, and cannot be moved.
To manipulate the position, remember to first set the CSS position property of the element to relative, fixed, or absolute!
jQuery animate() – Manipulate Multiple Properties

Notice that multiple properties can be animated at the same time:

Example
$(“button”).click(function(){
$(“div”).animate({
left: ‘250px’,
opacity: ‘0.5’,
height: ‘150px’,
width: ‘150px’
});
}); 

Solutie

Tip solutie

Permanent

Voteaza

(23 din 42 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?