0

hello people here is my ajax output...

$(function(){
    //after ajax request
    success:function(data){
        $('#inbox').html('<div class="inbox_user"  id='+data+'>'+data+'</div><br>')
    }
})

Div is creating successfully,so Iam very sure no issues with ajax code....but now i have to give click event to class .inbox_user ,,,its not working with no error message on console... click event for #inbox works fine..... any idea to fix this??

i am trying in normal way $('.inbox_user').click(function(){})

Friend
  • 1,326
  • 11
  • 38
  • 62

1 Answers1

2

try this :-

$(document).on('click', '.inbox_user',function(){
  alert(1);                                                
});

Demo

Umesh Sehta
  • 10,555
  • 5
  • 39
  • 68
  • yup its working... :) – Friend Jul 30 '14 at 09:22
  • 1
    Yup, this is right. With jQuery we used to use the 'live' bind event which checks for new elements after the DOM has loaded, however now 'on' handles this fine in the newer versions. – CarbonDry Jul 30 '14 at 09:26