i make a simple example in jquery .In my example user can added multiple entries using add
button.
Example "one" ,"two" .There is 'X' text in each entry .I am binding click event on 'X' span
.
https://jsfiddle.net/kzcozeeg/1/
Issue event is bind multiple times why ? example add two entry "one" and "two" .click "X" on first entry (one) .it show console message two times why ?
$(function() {
$('#btn').click(clickhandler)
function clickhandler(params) {
var user= $('.username').val();
var str = '<div><span>'+user +'</span> <span class="abc">X</span></div>'
$('#wrapper').append(str);
$('.abc').on('click',function () {
console.log($(this).prev('span').text())
})
}
})
Thanks