im trying to generate a element dynamically and bind the element to a click event using the below code..Everything works fine but the click event is not being triggered when I click datasource.
function create_datasource_facet(facetcount){
console.log(JSON.stringify(facetcount))
$('#filters').append('<div id="datafacet"></div>')
$.each(facetcount,function(index,value){
console.log(value);
console.log(index);
$('#datafacet').append('<br>')
$('#datafacet').append('<div id="datasource">' + index + '[' + value + '] </div>')
//$('#datafacet').append('<br>')
})
$(document).on('click','#datssource',function(){ alert('datasource clicked')})
}
$(document).on('click','#datssource',function()