Created
January 3, 2014 16:45
-
-
Save cgush/8241319 to your computer and use it in GitHub Desktop.
Hadouken from http://www.thinkful.com/learn/intro-to-jquery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $('#my-div').html('<img src="http://i.imgur.com/90Mmdcm.png">') | |
| $('#my-div img').hover( function() { | |
| this.src = 'http://i.imgur.com/nTj3Fxx.gif' | |
| }, function() { | |
| this.src = 'http://i.imgur.com/90Mmdcm.png' | |
| }) | |
| $('#my-div img').mousedown( function() { | |
| this.src = 'http://i.imgur.com/Rfj0a80.png' | |
| }) | |
| $('#my-div img').mousedown(function() { | |
| $('.demo-hadouken').remove(); | |
| }) | |
| $('#my-div img').mousedown(function() { | |
| $('#my-div').append( | |
| '<img class="demo-hadouken" src="http://i.imgur.com/oTyQRvX.gif">' | |
| ); | |
| }) | |
| $('#my-div img').mousedown(function() { | |
| $('audio')[0].load(); | |
| $('audio')[0].play(); | |
| $('.demo-hadouken').animate( { | |
| "margin-left": "600px" | |
| }, 1000, 'swing', function() { | |
| this.remove(); | |
| }); | |
| }) | |
| $('#my-div img').mouseup(function() { | |
| this.src = 'http://i.imgur.com/nTj3Fxx.gif' | |
| }) |
By the way, the above can clearly be optimised by caching selectors and combining the mousedown events. See https://gist.github.com/strangerpixel/9961244 or http://cdpn.io/rqIgs.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice!