What i want is, when click on (X) inside a button, then it should trigger the respective callback registered. But i dont know why it is failing. Below is what i tried:
HTML
<div id="cover"></div>
<template id='filtertemp'>
<button id="filtype" class='filbut' data-filter=""></button>
</template>
<button id='create' onclick="filter();">Click</button>
JQUERY
function filter(){
var content= $('#filtertemp')[0].content;
if(content){
var filType= content.querySelector('#filtype');
$(filType).text("type : sometype");
var clone= document.importNode(content,true);
$('#cover').append($(clone));
$('#cover > .filbut:last-child').append('<span class="glyphicon glyphicon glyphicon-remove"></span>');
}
$('.glyphicon').on('click', function(){
alert('Remove');
});
}
Here is the fiddle link: http://jsfiddle.net/wtce6dje/
I tried even below to register listener, but that too dint seemed to work:
$('body').on('click','.glyphicon', function(){
alert('Remove');
});