Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- $(document).keypress(function(e) {
- var key = e.which;
- if (key == 116) {
- // if the user pressed 't':
- if($(".red").hasClass("hidden"))
- {
- $(".red").removeClass("hidden").animate({
- opacity: "1"
- }, 500).css("z-index", 1);
- $(".blue").addClass("hidden").animate({
- opacity: "0"
- }, 500).css("z-index", 0);
- }
- else
- {
- $(".blue").removeClass("hidden").animate({
- opacity: "1"
- }, 500).css("z-index", 1);
- $(".red").addClass("hidden").animate({
- opacity: "0"
- }, 500).css("z-index", 0);
- }
- }
- });
- });
- <style>
- div.red
- {
- z-index: 1;
- }
- div.blue
- {
- opacity: 0;
- }
- </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement