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);" onclick="bgSwitch(this.style.backgroundImage);"></span>
<span style="background:url(http://3.bp.blogspot.com/-2G3W46D7VxU/T7xRiif7LWI/AAAAAAAACus/0_-eqSZoLjE/s72-c/efek-thread-comment-dengan-css.png);" onclick="bgSwitch(this.style.backgroundImage);"></span>
<span style="background:url(http://4.bp.blogspot.com/-ur039otofJ0/T8HGPzRaJnI/AAAAAAAAC4c/u4YuMB568vQ/s72-c/style-switcher.png);" onclick="bgSwitch(this.style.backgroundImage);"></span>
</div>
CSS
body {
padding:50px;
background-color:black;
background-size:100% auto;
background-position:50% 50%;
background-repeat:no-repeat;
}
#bgColorer {
overflow:hidden;
padding:15px;
background-color:rgba(0,0,0,.4);
}
#bgColorer span {
width:20px;
height:20px;
border:3px solid #333;
margin:0 5px 0 0;
float:left;
cursor:pointer;
}
JavaScript
var dbs = document.body.style;
function bgSwitch(v) {
dbs.backgroundImage = v;
}