5

I have a navigation that, when one of it's nav items is clicked, will use jQuery to change it's z-index to 0. Then, after 2 seconds, I would like the z-index to be changed to 2.

I tried using delay() but apparently that doesn't work when changing the CSS.

2
  • Do you just want the element to disappear and then after 2 seconds, reappear? There's better ways to make things disappear and reappear. like jQuery.show()/.hide() Commented Dec 10, 2010 at 17:50
  • Nope, I just wanted to change the z-index because it causes the links to be unclickable, but still visible, for 2 seconds Commented Dec 10, 2010 at 18:25

2 Answers 2

13

Use a setTimeout like this

$(elem).css('z-index','0');
setTimeout(function(){ $(elem).css('z-index','2'); },2000)
Sign up to request clarification or add additional context in comments.

Comments

2

In javascript you can use either setTimeout or setInterval to accomplish that

setTimeout("javascript statement",milliseconds);

http://www.w3schools.com/js/js_timing.asp

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.