JavaScript – Hide all divs by class and show one by ID

I need a JavaScript function that will allow me to change “display” property for one element to block but keep the others set to none (they are on top one another). Click image1 = display content1, but when you click image2, set content1 back to invisible and display content2 only.

<div id="imagesContainer">
  <img id="image0" onclick="function()">
  <img id="image1" onclick="function()">
  <img id="image2" onclick="function()">
  <img id="image3" onclick="function()">
</div>
<div id="contentContainer">
  <div id="content0">Lorem Ipsum</div>
  <div id="content1">Lorem Ipsum</div>
  <div id="content2">Lorem Ipsum</div>
  <div id="content3">Lorem Ipsum</div>
</div>

JavaScript – Hide all divs by class and show one by ID