Advertisement
Guest User

Code

a guest
Mar 20th, 2014
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. $(document).ready(function(){
  2.  
  3. $(document).keypress(function(e) {
  4. var key = e.which;
  5. if (key == 116) {
  6. // if the user pressed 't':
  7. if($(".red").hasClass("hidden"))
  8. {
  9. $(".red").removeClass("hidden").animate({
  10. opacity: "1"
  11. }, 500).css("z-index", 1);
  12. $(".blue").addClass("hidden").animate({
  13. opacity: "0"
  14. }, 500).css("z-index", 0);
  15. }
  16. else
  17. {
  18. $(".blue").removeClass("hidden").animate({
  19. opacity: "1"
  20. }, 500).css("z-index", 1);
  21. $(".red").addClass("hidden").animate({
  22. opacity: "0"
  23. }, 500).css("z-index", 0);
  24. }
  25. }
  26. });
  27.  
  28. });
  29. <style>
  30. div.red
  31. {
  32. z-index: 1;
  33. }
  34.  
  35. div.blue
  36. {
  37. opacity: 0;
  38. }
  39. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement