When you click on the first button it fires an onclick event attribute. You’ve told the event to find an element by the ID of ‘msg’. Which is the <p>
tag above.
It finds it and then replaces the innerHTML value of “Now you see me” with the string ‘Gone!’. Pretty much the same thing happens with the second button.
You can learn more about it at the web address below.
http://www.w3schools.com/tags/ev_onclick.asp
solved What does this HTML and JS do? [closed]