jquery animate() method中的if else语句

这个是来自java tutorial中的一段jquery animate()方法所涉及到的代码:
<!doctype html>







jQuery UI Effects - Animate demo







<br><br> .toggler { width: 500px; height: 200px; position: relative; }<br><br> #button { padding: .5em 1em; text-decoration: none; }<br><br> #effect { width: 240px; height: 135px; padding: 0.4em; position: relative; background: #fff; }<br><br> #effect h3 { margin: 0; padding: 0.4em; text-align: center; }<br><br>

<br><br> $(function() {<br><br> var state = true;<br><br> $( &quot;#button&quot; ).click(function() {<br><br> if ( state ) {<br><br> $( &quot;#effect&quot; ).animate({<br><br> backgroundColor: &quot;#aa0000&quot;,<br><br> color: &quot;#fff&quot;,<br><br> width: 500<br><br> }, 1000 );<br><br> } else {<br><br> $( &quot;#effect&quot; ).animate({<br><br> backgroundColor: &quot;#fff&quot;,<br><br> color: &quot;#000&quot;,<br><br> width: 240<br><br> }, 1000 );<br><br> }<br><br> state = !state;<br><br> });<br><br> });<br><br>



Animate

Javatpoint.com is the best tutorial website to learn Java and other programming languages.

Toggle Effect



问题是这个
1.state指向的是什么啊?2.if else语句又分别在这里起到什么作用?

请大家忽略上面关于javapoint.com的介绍。

1,state的作用是确定执行哪一个动画如果为true,执行第一个,否则执行第二个同时赋值state = !state也就是state = true;
2,用来判断state的状态,来执行哪一个动画

可是这里面只有一个动画效果啊 只写了一次animate{}?我理解你的意思是图中有多个animate().