day and night
by Adi Jaya
HTML
<h1 class="night">Coba diberi cahaya Sedikit</h1>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<button class="light" id="on">ON</button>
<button class="light" id="off" disabled>OFF</button>
CSS
body {
background: #181919;
text-align: center;
padding: 40px;
font-family: sans-serif;
color: #f1f1f1;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: 0;
}
body.on_light {
-moz-box-shadow: 0px 0px 200px 0px #232222 inset;
-webkit-box-shadow: 0px 0px 200px 0px #232222 inset;
box-shadow: 0px 0px 200px 0px #000000 inset;
background: rgba(0, 0, 0, 0.17);
}
h1.night {
color: #272626;
text-shadow: -2px 2px #444444;
}
h1.light {
color: #ffffff;
text-shadow: -2px 2px #444444;
}
button.light {
padding: 10px;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
border-radius: 50px;
border: none;
min-width: 70px;
background: #eca92e;
outline: none;
cursor: pointer;
font-weight: bold;
}
button.light:disabled {
cursor: no-drop;
background: #a8abab;
color: #efeeec;
}
JavaScript
$(function () {
var a = $('#on'),
b = $('#off'),
c = $('body');
$('.light').click(function() {
$('.light').prop('disabled',false);
$(this).prop('disabled',true);
});
a.click(function() {
c.addClass('on_light');
$('h1')
.removeClass('night')
.addClass('light')
.text('Gini Kan Lebih Enak');
});
b.click(function() {
c.removeClass('on_light');
$('h1')
.removeClass('light')
.addClass('night')
.text('Ahh.. Abang, Sukanya yang Gelap-Gelap');
});
});