Live Chat Slide Out Window

by Chris Nicholson

HTML

<div id="LiveChat">
    
    <a href="#">Live Chat</a>
    
    <div>
        <div>
            <span>Phone</span>
            <a href="#">Button</a>
        </div>
    </div>
    
</div>

CSS

#LiveChat {
    position: absolute;
    right: 0;
    top: 50px;
    background: blue;
}

#LiveChat > a {
    display: block;
    width: 50px;
    height: 200px;
    float: left;
    background: red;
}

#LiveChat > div {
    width: 0;
    height: 200px;
    overflow: hidden;
    float: left;
    background: yellow;
}

#LiveChat > div > div {
    width: 250px;
    height: 200px;
    background: lime;
}

JavaScript

$('#LiveChat > a').toggle(function(e){
    
    e.preventDefault();
    $('#LiveChat > div').animate({ 'width': '250px' });
    
}, function(e){
    
    e.preventDefault();
    $('#LiveChat > div').animate({ 'width': '0' });    
    
});