0

Sorry my bad English ı append new data using ajax like this

<span class="commentbuton" id="143">Comment..</span>

and javascript is

$(function(){
    $(".commentbuton").click(function() { ...

but its not working on new appended data please help thanks.

Barmar
  • 596,455
  • 48
  • 393
  • 495

1 Answers1

0

You need to bind the click listener after the element is inserted into the page. My guess is that you bind the click handler before the existance of ".commentbutton".

$('body').html('<div class="commentbutton"></div>')
//bind after commentbutton inserted
$(".commentbuton").click(function() { ... });

Does this help?