Last active
December 30, 2015 19:49
-
-
Save nola/7876841 to your computer and use it in GitHub Desktop.
jquery .on with event. New and Old way with bind
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
| $('body').on({ | |
| click: function() { | |
| event.preventDefault(); | |
| console.log('item anchor clicked'); | |
| }, | |
| mouseenter: function() { | |
| console.log('enter!'); | |
| } | |
| }); | |
| // old way - .bind(events, handler); | |
| $('body).bind('click', function(event) { | |
| event.preventDefault(); | |
| console.log('item anchor clicked'); | |
| }); | |
| // new way (jQuery 1.7+) - on(events, handler); | |
| $('body').on('click', function(event) { | |
| event.preventDefault(); | |
| console.log('item anchor clicked'); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment