Insert comment Response form on page using jQuery

I am doing a multi-threaded comment system as a way to learn php and javascript / jquery correctly. Ive been making beats and beans in the past, but ive made a new resolution of the year to learn it properly.

I am having trouble inserting a response form into the comment tree below the comment that was answered. I know this is probably pretty simple, but how do you embed html on a page when someone clicks on a link.

This code did not work for me:

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

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

        });
    });

}); 

Does anyone see where I'm wrong?

+5
source share
3 answers

, , . , , , :

<a id='reply' href='#'>add comment</a>

? , html, asp.net != , :

$('a[id$=reply]')

, html, :

<html>
    <head>
        <script type="text/javascript" src='scripts\jquery-1.2.6.min.js'></script>
    </head>
    <body>
        <div style='height:400px'>
            Space to demonstrate that clicking the link does not scroll the page.
        </div>
        <div id='main'>
            <a href='#' id='clicky'>here</a>
        </div>
    </body>
    <script>
        $(function(){
            $('a#clicky').click(function(){
                $(this).after('Hello There')
                return false;
            });
        });
    </script>
</html>
+2
$(document).ready(function(){
        $('a#reply').click(function() {
            $(this).after("the html blah");
            return false;
        });
});

"return false"; , .

+3

rodbv, "html blah blah" , , append. :

$(this).after("the html");

html .

+1

All Articles