Created
October 25, 2012 20:52
-
-
Save ungoldman/3955315 to your computer and use it in GitHub Desktop.
jQuery click bind switch example
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
| <!DOCTYPE HTML> | |
| <html lang="en-US"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title></title> | |
| </head> | |
| <body> | |
| <a href="#" class="button">hi</a> | |
| <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script> | |
| <script type="text/javascript"> | |
| $(document).ready(function(){ | |
| var $button = $('.button'); | |
| function bindOne(event){ | |
| event.preventDefault(); | |
| $(this).unbind('click.woot').on('click.woot', bindTwo); | |
| console.log('woot 1'); | |
| } | |
| function bindTwo(event){ | |
| event.preventDefault(); | |
| $(this).unbind('click.woot').on('click.woot', bindOne); | |
| console.log('woot 2'); | |
| } | |
| $button.on('click.woot', bindOne); | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment