JavaScript is a scripting or programming language that allows you to implement complex features on web pages — every time a web page does more than just sit there and display static information for you to look at — displaying timely content updates, interactive maps, animated 2D/3D graphics, scrolling video jukeboxes, etc. — you can bet that JavaScript is probably involved. It is the third layer of the layer cake of standard web technologies, two of which (HTML and CSS) are also covered on this wesite.
JavaScript can change HTML content.
In this case JavaScript changes the value of the src (source) attribute of an image.
Changing the style of an HTML element, is a variant of changing an HTML attribute:
JavaScript can change the style of an HTML element.
Hiding/showing HTML elements can be done by changing the display style:
JavaScript can hide and show HTML elements.