jQuery - cannot bind events to dynamic elements?
问题 I've come to maintain a piece of javascript that downloads some JSON data from the server, builds a new table row (like $('<tr></tr') ) and inserts it into the document. The a node is, at one point created like this: var a = $('<a class="foo" href="#"></a>'); and later, an event is bound to it like this: a.click(function () { // yadda yadda return false; }); The only problem is that this doesn't seem to work. Neither does binding through on() or the deprecated live() . The handler is simply