Site calculatrice

https://openclassrooms.com/forum/sujet/site-calculatrice

<!DOCTYPE html>
<html >
<head>
  <meta charset="UTF-8">
  <title>Site calculatrice</title>
  
  
  
  
  
</head>

<body>
  <h1 id="titre"> Calculatrice </h1>
        <div id="calculatrice">
            <input type="text" id="resultat" name="resultat" value="0"/>
            <input type="button" id="b7" style="width:100px;" class="calc_btn" value="7"/>
            <input type="button" id="b8" style="width:100px;" class="calc_btn" value="8"/>
            <input type="button" id="b9" style="width:100px;" class="calc_btn" value="9"/>
            <input type="button" id="bP" style="width:100px;" class="calc_btn" value="+"/>
            <br>
            <input type="button" id="b4" style="width:100px;" class="calc_btn" value="4"/>
            <input type="button" id="b5" style="width:100px;" class="calc_btn" value="5"/>
            <input type="button" id="b6" style="width:100px;" class="calc_btn" value="6"/>
            <input type="button" id="bMo" style="width:100px;" class="calc_btn" value="-"/>
            <br>
            <input type="button" id="b1" style="width:100px;" class="calc_btn" value="1"/>
            <input type="button" id="b2" style="width:100px;" class="calc_btn" value="2"/>
            <input type="button" id="b3" style="width:100px;" class="calc_btn" value="3"/>
            <input type="button" id="bM" style="width:100px;" class="calc_btn" value="*"/>
            <br>
            <input type="button" id="bV" style="width:100px;" class="calc_btn" value=","/>
            <input type="button" id="b0" style="width:100px;" class="calc_btn" value="0"/>
            <input type="button" id="bE" style="width:100px;" class="calc_btn" value="="/>
            <input type="button" id="bD" style="width:100px;" class="calc_btn" value="/"/>
        </div>
  
    <script  src="js/index.js"></script>

</body>
</html>
/* Downloaded from https://www.codeseek.co/ */
/* Downloaded from https://www.codeseek.co/ */
var b1=document.getElementById("b1"), b2=document.getElementById("b2"), b3=document.getElementById("b3"), bP=document.getElementById("bP");
var b4=document.getElementById("b4"), b5=document.getElementById("b5"), b6=document.getElementById("b6"), bMo=document.getElementById("bMo");
var b7=document.getElementById("b7"), b8=document.getElementById("b8"), b9=document.getElementById("b9"), bM=document.getElementById("bM");
var bV=document.getElementById("bV"), b0=document.getElementById("b0"), bE=document.getElementById("bE"), bD=document.getElementById("bD");
var resultat=document.getElementById("resultat");
 
b0.addEventListener("click", function(e) {
    resultat.value+=b0.value;
});
b1.addEventListener("click", function(e) {
    resultat.value+=b1.value;
});
b2.addEventListener("click", function(e) {
    resultat.value+=b2.value;
});
b3.addEventListener("click", function(e) {
    resultat.value+=b3.value;
});
b4.addEventListener("click", function(e) {
    resultat.value+=b4.value;
});
b5.addEventListener("click", function(e) {
    resultat.value+=b5.value;
});
b6.addEventListener("click", function(e) {
    resultat.value+=b6.value;
});
b7.addEventListener("click", function(e) {
    resultat.value+=b7.value;
});
b8.addEventListener("click", function(e) {
    resultat.value+=b8.value;
});
b9.addEventListener("click", function(e) {
    resultat.value+=b9.value;
});
bP.addEventListener("click", function(e) {
    resultat.value+='+';
});
bMo.addEventListener("click", function(e) {
    resultat.value+='-';
});
bM.addEventListener("click", function(e) {
    resultat.value+='*';
});
bD.addEventListener("click", function(e) {
    resultat.value+='/';
});
bE.addEventListener("click", function(e) {
    resultat.value+='=';
});
bV.addEventListener("click", function(e) {
    resultat.value+='.';
});

This awesome code ( Site calculatrice ) is write by Deejayfool, you can se more from this user in the personal repository

You can find the original code on Codepen.io

2018 © Deejayfool