The hyperlink is redirected. This causes innerHTML to be set, then the page reloads back to its original state. If you work on a local machine, it can be so fast that you can do this Javascript. (Upload it to the web server and you will see that reloading the page is much clearer).
Try changing the code to:
<p><a href="#" onclick="getNbr();return false;">get a number</a></p>
, , #.
(;) onclick , . , , :
"getNbr();anotherFunc();yetAnother();return false;"
false (# href , , ).