Tuesday, May 21, 2024
 Popular · Latest · Hot · Upcoming
29
rated 0 times [  34] [ 5]  / answers: 1 / hits: 5465  / 10 Years ago, wed, april 16, 2014, 12:00:00

Hey so I have a div that I want to replaceWith some text after clicking on the button and then re-show the same hidden text after 5 seconds. I am stuck on the part where I need to re-show it. I hid the div with the onclick function and appended some text but after a couple seconds I would like to re-show the original text.



here is the link that I need to change text onclick and then after 5 seconds show the ORIGINAL text...



originally the text says add to calendar, upon clicking it, it should change to calendar updated and then after 5 seconds change back to add to calendar.



<div class=resSubmitAction download resDetailsButton>
<a href=javascript:void(0);>
</div>
<div class=calText><p>add to calendar</p></div></a>
</div>


Jquery:



$(document).ready(function () {
$(.resSubmitAction).click(function () {
$(.calText > p).replaceWith(Calendar Updated);
});
});

More From » jquery

 Answers
3

Make use of the setTimeout function. Fiddle



$(#clickme).click(function(){
var elem = $(this);
setTimeout(function(){
elem.hide();
}, 5000);
});

[#45965] Tuesday, April 15, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
keric

Total Points: 572
Total Questions: 93
Total Answers: 97

Location: Cyprus
Member since Mon, Oct 24, 2022
2 Years ago
;