jQuery on() method not working for appended elements
- by behz4d
I know I should use on() method for triggering appended elements and not use click(), so:
$('#change_profile_img').on('click', function(){
alert(1);
});
so the above code is working fine on any elements unless the appended elements, for example, I'm appending:
$('.companylogo:first').append('<a id="change_profile_img" class="ic_change">CHANGE IMAGE</a>');
after it's appended, it's not working, but after a page refresh it works just fine.
Another thing that I should mention, I'm doing the append from a modal page, it appends the button and everything but I could not trigger it anymore...
I would appreciate any kind of help.
Thanks