<!DOCTYPE html>
<html>
<header>
<script>
$(document).ready(function(){
$("#image").hide();
$("#clickIt").click(function(){
function ChangeIt(){
var totalCount = 5;
var num = Math.ceil( Math.random(2) * totalCount );
return num;
}
var speed = ChangeIt();
$("#Body img").fadeIn(speed, linear);
});
});
</script>
</header>
<body id="Body">
<img id="#image" src="../apple.png" alt="img">
<button id="clickIt"/> go </button>
</body>
</html>
Just to point you in the right direction you can do fadeIn and fadeOut using jquery. Above is an example of what that might look like I'm sure it will be different for your needs but check out the documentation for fadein on jquery's website jquery fadein api