Diskusi untuk Style Switcher dengan Cookies

by Taufik Nurrohman

HTML

<div id="bgColorer">
    <span style="background:url(http://1.bp.blogspot.com/-4svgARDkkX8/T7zvlPbcl_I/AAAAAAAACu4/pmMi0Ardkb8/s72-c/basic-tab.png) repeat;" onclick="bgSwitch(this.style.background);"></span>
    <span style="background:url(http://3.bp.blogspot.com/-2G3W46D7VxU/T7xRiif7LWI/AAAAAAAACus/0_-eqSZoLjE/s72-c/efek-thread-comment-dengan-css.png) repeat;" onclick="bgSwitch(this.style.background);"></span>
    <span style="background:url(http://4.bp.blogspot.com/-ur039otofJ0/T8HGPzRaJnI/AAAAAAAAC4c/u4YuMB568vQ/s72-c/style-switcher.png) repeat;" onclick="bgSwitch(this.style.background);"></span>
</div>

CSS

body {
  padding:50px;
  background-color:black;    
}

#bgColorer {
  overflow:hidden;
  padding:15px;
  background-color:rgba(0,0,0,0.4);    
}

#bgColorer span {
  width:20px;
  height:20px;
  border:3px solid #333;
  margin:0px 5px 0px 0px;
  float:left;
  cursor:pointer;    
}

JavaScript

var dbs = document.body.style;
function bgSwitch(v) {
    dbs.background = v;
}