<!DOCTYPE HTML>
<html>
<head> </head>
<body>
<div style="width: 200px;height: 100px;background: red;display: none;" id="mydiv"></div>
<button onclick="clk();">Click me</button>
<script>
var t, mydiv = document.getElementById('mydiv');
function clk() {
clearTimeout(t);
mydiv.style.display='block';
t = setTimeout(function() { mydiv.style.display='none'; }, 3000);
}
</script>
</body>
</html>