I'm trying to make a simple calculator. I have a div called result, which I have called in jQuery. Whenever I click on the button (number) I want it's value to add onto the string. After I have a string like "5 + 2 + 3" I want to change it to an expression then return the result.
For now all I want is to add the value of the button to the string.
http://codepen.io/kreitzo/pen/RapEqp
index.html
<div id="calculator">
<button class="value">1</button>
<button class="value">2</button>
<button class="value">3</button>
<button class="value">4</button>
<button class="value">5</button>
<button class="value">6</button>
<button class="value">7</button>
<button class="value">8</button>
<button class="value">9</button>
<button class="value">0</button>
<button class="value">+</button>
<button class="value">-</button>
<button class="value">÷</button>
<button class="value">*</button>
<div id="result"></div>
</div>
script.js
$(document).ready(function(){
var string = $("#result");
string = "";
$(".value").click(function(){
string += $(this).toString();
});
});