The animate () method sets multiple properties at once:
This method creates a custom animation for the matching element, for example, you can set the width of a div to 200px, and the code example is as follows:
<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.softwhy.com/" /><title>Ant Tribe</title><styletype= "Text/css">Div{width:150px;Height:150px;Background-color:Green;}</style><Scripttype= "Text/javascript"src= "Mytest/jquery/jquery-1.8.3.js"></Script><Scripttype= "Text/javascript">$ (document). Ready (function(){ $("Button"). Click (function(){ $("Div"). Animate ({"width":"200px"}) }) }); </Script></Head><Body><Div></Div><Button>Click Settings</Button></Body></HTML>
The above code successfully sets the width of the div to 200px, but in practice it is often necessary to set multiple attribute values for matching elements. The code example is as follows:
<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.softwhy.com/" /><title>Ant Tribe</title><styletype= "Text/css">Div{width:150px;Height:150px;Background-color:Green;}</style><Scripttype= "Text/javascript"src= "Mytest/jquery/jquery-1.8.3.js"></Script><Scripttype= "Text/javascript">$ (document). Ready (function(){ $("Button"). Click (function(){ $("Div"). Animate ({"width":"200px","Height":"300px"}) }) }); </Script></Head><Body><Div></Div><Button>Click Settings</Button></Body></HTML>
The above code sets the width and height of the div at the same time by adding a comma between each set of attribute/value pairs.
The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=5803
For more information, refer to: http://www.softwhy.com/jquery/
Animate () method to set multiple properties at once