I have a page that is pulling content in from firebase and appending it to the page:
code:
function displaySavedData(Name, Company, Email, Phone, snap) {
$('.data').append('<div class="each-container" data-del="'+snap+'"><div class="del">X</div><div class="row-margin"><div class="new-row-one">'+'Name: '+Name+'<br>'+'Company: '+Company+'<br>'+'Email: '+Email+'<br>'+'Phone: '+Phone+'</div></div></div>');
};
There is a div in there, for each div is added to the page is given a class of del
with an X to display. I am trying to get a click event to work when that X is clicked but since the class is not present on the page as it loads the click event does not register. How can I get this to work after the page loads?
click event:
$('.del').click(function(){
console.log('clicked');
});
JSFiddle: http://jsfiddle.net/0a5s7uLk/1/