Powered by Blogger.

Click Event not working for Dynamically Created Button-jQuery


As the button is dynamically  created, you need to call them with .live() method if you use jquery 1.7
but this method is deprecated (you can see the list of all deprecated methods here) in a newer version.
If you want to use jquery 1.10 or above you need to call your buttons in this way:
$(document).on('click','selector',function(){
// Your Code});
For Example
if your HTML something like this
id="btn-list">
class="btn12">MyButton
</div>
you can write your jquery like this
$(document).on('click','#btn-list .btn12',function(){
 // Your Code});

No comments