javascript - click function after dynamically changing data using .html() -


this question has answer here:

i trying implement click function inside div nested children tags such span, td, etc. however, these nested tags loaded dynamically, using ajax(). returned result displayed using .html(data) function. however, once data changed , new tags added, old javascript written detect clicks no longer work.

i want know if there way make work?

an example of talking can found here.

you supposed attach event handler on wrapper element so:

http://jsfiddle.net/v4sfw/1/

$("#testing").on("click", "span", function() {     alert("now?"); }); $("#testing").html("<span>how now?</span>"); 

Comments