earwig75
asked on
Toggle a div with a button and timer with jQuery
I am using the below to toggle a div with jQuery. I would like to make it so that after the initial button click/toggle happens, after 5 seconds, it runs once again by itself to show "Div 1" again... and then stops. Could someone assist?
//HTML
<div class="myDiv ">Div 1</div>
<div class="myDiv hidden">Div 2</div>
<input type="button" value="Toggle Me" id="toggle">
//jQuery
$('#toggle').click(function() {
$('.myDiv').toggleClass('hidden');
});
//CSS
.hidden {display: none; }
ASKER
@Huseyin, that Does not show Div 1 again after 5 seconds, it continues to show Div 2.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect thank you.
Open in new window