jQuery click / toggle between two functions

http://stackoverflow.com/a/18287434/2507142

by katalin_2003

HTML

<div id="time">
    <p>You can see this if you click</p>
</div>

CSS

#time {
    background:#ddd;
    width:30px;
    height:80px;
    white-space:nowrap;
    overflow:hidden;
    cursor:pointer;
}
#time p {
    margin-left:35px;
}

JavaScript

function handler1() {
    $(this).animate({
        width: "260px"
    }, 1500);
    $(this).one("click", handler2);
}

function handler2() {
    $(this).animate({
        width: "30px"
    }, 1500);
    $(this).one("click", handler1);
}
$("#time").one("click", handler1);