Fix jQuery toggle button

by audetwebdesign

HTML

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/ui-lightness/jquery-ui.css">
<div id='topbar'>toggle me</div>

CSS

#topbar {
    background: orange;
    color: white;
    height: 10px;
    text-align:center;
    margin-top: 50px;
}

JavaScript

$("#topbar").toggle(function () {
    $(this).animate({
        height: 40px
    }, 200);
}, function () {
    $(this).animate({
        height: 10px
    }, 200);
});