Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class='Row1'>
- <button class="clear" id="allClear">AC</button>
- <button id="plus-minus">+/-</button>
- <button class="operators" id="decimal">.</button>
- <button class="operators divide">÷</button>
- </div>
- </td>
- </tr>
- <!-- new line -->
- <tr>
- <td>
- <div class "row2">
- <button class="num-button seven">7</button>
- <button class="num-button eight">8</button>
- <button class="num-button nine">9</button>
- <button class="operators multiply">x</button>
- </div>
- </td>
- </tr>
- $('.operators').click(function(){
- if(check()) {
- $('.display').val('ERR');
- } else {
- var displayVal = $('.display').val();
- operator = $(this).text();
- var showOpp = displayVal + operator;
- $('.display').val(showOpp);
- }
- });
- /*
- * Takes display value as a string and does calculation
- */
- $('#equal').click(function() {
- var calculation = $('.display').val();
- var operatorIndex = calculation.indexOf(operator);
- var value1 = parseFloat(calculation.slice(0,operatorIndex));
- var value2 = parseFloat(calculation.slice(operatorIndex+1));
- console.log(value1);
- console.log(value2);
- var operation = '';
- switch(operator) {
- case '÷':
- operation = divide(value1,value2);
- break;
- case 'x':
- operation = multiply(value1,value2);
- break;
- case '+':
- operation = add(value1,value2);
- break;
- case '-':
- operation = sub(value1,value2);
- break;
- }
- $(".display").val(operation);
- })
- $('#decimal').click(funciton(){
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement