Background color toggle div

A simple implementation of toggleClass, used to change background colors

by Alan Guerrero

HTML

<div class="bgtoggle">
</div>

CSS

.bgtoggle{
    position: absolute;
    width: 56px;
    height: 43px;
    right:65px;
    top:170px;
    color:#fff;
    font-size: 3em;
    cursor:pointer;
    z-index:9999;
    /*background-image: url("../images/mthc/bgtoggle.png");*/
    background-color: red;
    background-size: 100%;
}

.bgtoggle:hover{
    background-color: blue;
}

body {
    /* set the background to whatever you like, I made it white in color */
    background-color: white;
}

.bgcolor--yellow {
    background-color: yellow;
}

JavaScript

jQuery(document).ready(function(){
    jQuery(".bgtoggle").click(function () {
        jQuery("body").toggleClass("bgcolor--yellow");
    });
});