simple version of jquery live function
问题 Is it possible to get anywhere a pure javascript function for event handler with similar functionality as jquery's live() ? I need to have the ability to attach events to objects not yet created but both jquery-livequery as well as jquery-events sources are not useful due to dependencies on jquery core. 回答1: Event delegation is quite simple. Take this example: Markup: <div id="container"> <p>Test</p> <p>Test</p> <p>Test</p> </div> <button id="add">Add new paragraph</button> Script: document