I'm using jquery to click toggle a list element created with createElement()
but it doesn't work. The html elements display correct but the click function doesn't fire.
$.getJSON(endpoint, function(result) {
$.each(result, function (i, v) {
if(v.comment !== null){
listItem = document.createElement("div");
listItem.classList.add('row','comment-item');
listItem.innerHTML = '<div id="toggle-comment-options"><ul id="comment-options" style="display:none"><li>Edit</li><li>Delete</li></ul></div>';
document.getElementById("comments").appendChild(listItem);
}
});
});
$("#toggle-comment-options").click(function(){
var list = $("#comment-options");
$(list).fadeToggle();
});