Understanding event bubbling in javascript
问题 I've been trying to understand even bubbling, and not quite sure I completely follow it. I started reading about it so that I could warn users when they were leaving a page on my website if they had started to enter data into a form (in a similar way to StackOverflow does!). The following code seems to work cross-browser: var entereddata = false; $(document).ready(function() { $('#contactform').bind('keypress',function(e) { if((e.which > 96 && e.which < 123) || (e.which > 47 && e.which < 58))