Hello I have two questions I pulled this script from the jQuery UI site, here is the link to the full code http://jqueryui.com/animate/
1) What is the purpose of the var = state? Could you just use the boolean true in the if statement instead?
2) Just after the if/else statement you can see var = !state. What is the purpose of this and what does the ! mean?
<script>
$(function() {
var state = true;
$( "#button" ).click(function() {
if ( state ) {
$( "#effect" ).animate({
backgroundColor: "#aa0000",
color: "#fff",
width: 500
}, 1000 );
} else {
$( "#effect" ).animate({
backgroundColor: "#fff",
color: "#000",
width: 240
}, 1000 );
}
state = !state;
});
});
</script>