I'm trying to create a calculator, getting the values from buttons 1 to 9. Now I'd like to add a value to the textbox instead of setting it, like I want the user to be able to add 1 then 5 to make it a total of 15. How can I achieve this?
.prop
sets a value, or .val
so that one is out of the list.
<script>
jQuery(document).ready(function () {
jQuery("#one").click(function () {
jQuery("#entered").prop("value", "1");
});
});
</script>
CSS part:
<div>
<button id="one">1</button>
<button id="two">2</button>
<button id="three">3</button>
<button id="four">4</button>
<button id="five">5</button>
<button id="six">6</button>
<button id="seven">7</button>
<button id="eight">8</button>
<button id="nine">9</button>
<input type="text" id="entered" disabled="disabled" />
</div>