Difference between .on('click') vs .click()
问题 Is there any difference between the following code? $(\'#whatever\').on(\'click\', function() { /* your code here */ }); and $(\'#whatever\').click(function() { /* your code here */ }); 回答1: I think, the difference is in usage patterns. I would prefer .on over .click because the former can use less memory and work for dynamically added elements. Consider the following html: <html> <button id="add">Add new</button> <div id="container"> <button class="alert">alert!</button> </div> </html> where