Event delegation code could be much simpler when using jQuery.