Learn Create Your Own Split Screen

Next Page

Now we define the PressNumberButton function.

This will simply make another digit appear on the calculator display.

We gave our readout div an id of numdisplay. We can use the Javascript += operator to perform a string concatenation (join) of the new digit onto whatever is already there. We use the innerText property of the div.

function PressNumberButton (n) { numdisplay.innerText += n; }

Try clicking a number button.