JSFiddle - React, Tailwind, and code Playground

HTML

<img id="slot1" src="http://chandra.harvard.edu/graphics/photo/high_res_thm.jpg"  onclick="function1()">
<img id="slot2" src="http://umbra.nascom.nasa.gov/images/latest_mk4_icon.gif"  onclick="function2()">
<input type="button" id="button" onclick="shuffleImages()" value="Click"/>

JavaScript

function shuffleImages(){
	var src1 = document.getElementById("slot1").getAttribute('src');
  var src2 = document.getElementById("slot2").getAttribute('src');
  var click1 = document.getElementById("slot1").getAttribute('onclick');
  var click2 = document.getElementById("slot2").getAttribute('onclick');
  document.getElementById("slot1").setAttribute("src", src2);
  document.getElementById("slot1").setAttribute("onclick", click2);
  document.getElementById("slot2").setAttribute("src", src1);
  document.getElementById("slot2").setAttribute("onclick", click1);
}