JSFiddle - React, Tailwind, and code Playground

HTML

<div id="gallery" style="border:1px solid red; height: 400px">
<img src="http://imgsrc.hubblesite.org/hu/db/images/hs-2002-10-c-web.jpg" width="400" height="376">
<img src="http://imgsrc.hubblesite.org/hu/db/images/hs-2007-01-g-web.jpg" width="400" height="388">
</div>

JavaScript

$("#gallery").mouseenter(function() {
   var gallery = this;

   $("img", this).each(function() {
      var prev = {
        "width": $(this).attr("width"),
        "height": $(this).attr("height")
      };

      var img = this;

      $(gallery).one("mouseleave", function() {
        $(img).attr(prev);
      });
   }).attr({'height':'20px', 'width':'20px'});
});