这个是来自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> $( "#button" ).click(function() {<br><br> if ( state ) {<br><br> $( "#effect" ).animate({<br><br> backgroundColor: "#aa0000",<br><br> color: "#fff",<br><br> width: 500<br><br> }, 1000 );<br><br> } else {<br><br> $( "#effect" ).animate({<br><br> backgroundColor: "#fff",<br><br> color: "#000",<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语句又分别在这里起到什么作用?