Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert Comment Reply Form Into Page Using Jquery

I have been making a threaded comment system as a way to learn php and javascript/jquery properly. Ive done bits and bobs in the past but ive made a new years resolution to learn it properly.

Im having trouble inserting a reply form into the comment tree below the comment being replied to. I know this is probably pretty basic but how do you insert html into a page when someone clicks a link.

This code wasn't working for me:

$(document).ready(function(){
    $(function() {
        $('a#reply').click(function() {

            $(this).append("the html blah");    

        });
    });

}); 

Anyone see where im going wrong?

like image 495
Joe Avatar asked Jan 19 '09 14:01

Joe


1 Answers

$(document).ready(function(){
        $('a#reply').click(function() {
            $(this).after("the html blah");
            return false;
        });
});

You may need the 'return false;' in there to stop the page from reloading itself when you click on the link.

like image 130
Corey Downie Avatar answered Sep 28 '22 08:09

Corey Downie