<input type="text"><button>=</button> <script> var input = document.querySelector('input'); document.querySelector('button').onclick = e => input.value = eval(input.value); </script>