I am having troubles binding live events to dynamically created content.
I have a page which loads a html page through an ajax call. The loaded html page contains some javascript which is then executed. The executed javascript creates some elements.
I want to bind a click event handler to those el开发者_如何学Cements, however after binding them (using .live, .delegate and plain old .click) nothing happens after clicking on them.
I am able to retrieve the contents of the elements (by calling .html) but I can't bind events on them for some reason...
I have also tried adding onclick="alert('test');" to the elements before spitting them out through javascript but to no avail...
Anyone know of a solution?
Thanks
John,
take a look at the .livequery() plugin. this will give you a full range that includes the .live() event plus other callback scenarios.
http://docs.jquery.com/Plugins/livequery
jim
精彩评论