Kilogramm in Pfund umrechnen
by shapeshifta
HTML
<h1 class="logo">Body Beast</h1>
<ul>
<li>
<label class="bold" for="kilo">Kilogramm</label>
<input class="insert" id="kilo" type="text" value="12"/>
</li>
<li>
<label class="bold" for="pound">in Pfund</label>
<input id="pound" type="text" value="0"/>
</li>
</ul>
CSS
body{font:14px Arial;background:#000;width:700px;color:#fff}
.logo{background:url(http://www.extremely-fit.com/fitness-tips/wp-content/uploads/2012/05/body_beast.png) 0 -67px;text-indent:-9999px;height:101px;width:234px;margin-bottom:20px}
ul{margin:0; padding:0 1em 1em;width:600px }
label{display:block; float:left; margin-top:16px; padding-right:1em;width:355px;text-align:right;cursor:pointer}
input, select{ margin-top:14px; padding:0; vertical-align:bottom }
.bold, strong{font-weight:bold}
.insert{outline:2px solid}
.insert:focus{outline:2px solid #88C63D;transition:.2s}
::selection{color:#fff;background:#8DC53C}
::-moz-selection{color:#fff;background:#8DC53C}
JavaScript
var $ = function(selector) {
return document.querySelectorAll(selector);
},
$kilo = $('#kilo')[0],
$pound = $('#pound')[0],
calculate = function() {
$pound.setAttribute('value', $kilo.value * 2.204622622);
};
$kilo.addEventListener('keyup', calculate, false);
$pound.addEventListener('keyup', calculate, false);
document.addEventListener("DOMContentLoaded", calculate, false);