Can you please help me by creating such javascript code which can load a certain button after a fixed time and also for fixed interval of time.
Like I want my site to show a hyperlink button after every five hours and for 20 min in each time. And disappear is the rest time.
I am stuck here and didn’t know how to do that. Any ideas…??
Hey, this code displays a button after 5 seconds. The button will stay on the screen for 5 seconds, then it will vanish again. It will reappear after 5 seconds for a further 5 seconds and so on. This is a rather naive implementation, but it should serve you as a starting point for attempting to do what you want.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Show/hide button</title>
</head>
<body>
<button id="myButton">Click Me!</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
function hideButton(){
$("#myButton").hide();
setTimeout( () => { displayButton(); }, 5000);
}
function displayButton(){
$("#myButton").show();
setTimeout( () => { hideButton(); }, 5000);
}
hideButton();
</script>
</body>
</html>
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.