$(document).ready(function() { $(’#ad’).show(); var time = 30; var timer = setInterval(function() { time—; $(’#time’).html(‘This ad will close in ‘time‘ seconds.’); if (time == 0) { $(’#ad’).hide(); clearInterval(timer); } }, 1000); $(’#close_ad’).click(function() { $(’#ad’).hide(); }); }); This ad will close in 30 seconds.