I'm trying to make the click event work for a list of dynamically added buttons.
See this jsfiddle: https://jsfiddle.net/jeffxiao/u1dc57za/5/
the failing line is:
$(".run").on('click', 'ul#mitigationList', clickFunction);
Any feedback is welcome.
I'm trying to make the click event work for a list of dynamically added buttons.
See this jsfiddle: https://jsfiddle.net/jeffxiao/u1dc57za/5/
the failing line is:
$(".run").on('click', 'ul#mitigationList', clickFunction);
Any feedback is welcome.
 
    
    Use this click event code :
$(document).on("click", ".run", function(){
alert("Clicked!");
});
Working jsfiddle : https://jsfiddle.net/rajnikpatel/76nmazcf/
 
    
    This issue is that $('.run').on('click', 'ul#mitigationList', clickFunction) will look for clicks on ul#mitigationList descendants of .run elements which isn't what you want.
Think of it like this:
$('elementsToWatch').on('eventName', 'descendants', functionToRun)
Have updated your fiddle:
 
    
    try this:
 $("html body").on('click', '.run', clickFunction);
jsfiddle: https://jsfiddle.net/u1dc57za/12/
