How To implement the Javascript to elements which has been added to head section of HTML By Jquery prepend()?
<p>I have this in my head section.</p>

<pre><code>&lt;script type="text/javascript" src="post.js"&gt;&lt;/script&gt;
</code></pre>

<p>I want this post.js to be also be implemented to the newly created elements.My another <em>js file</em> which is named as main.js have a code that get data from another php file and prepend it in a div with id display.Previous Loaded Div works great with the post.js file but as new elements are prepended, it does not work for new ones. Here is my main.js code which get data from php file and prepend it:</p>

<pre><code>var auto_refresh8 = setInterval(function() {
    var id = "id="+$(".ally:first").attr("id");
    $.ajax({
        type: "POST",
        url: "get_post.php",
        data: id,
        cache: false,
        success:function(html){
            $('#display').prepend(html);
        }
    });
},2000);
</code></pre>

<p>this jquery ajax request get data from get_post.php file and prepend it to the div display. but the code in post.js doesn't work with this.The data returned by jquery ajax request contains a div with class comm which have to submitted when keypress function acts.</p>

<p>following is the code of post.js :</p>

<pre><code>$(document).ready( function() {
    $(".comm").keypress(function(e) {
        if(e.which == 13) {
            var id = $(this).attr("id");
            var data = 'id=' + id;
            var post = $(this).val();
            var data1 = 'comment='+post;
            var wholedata = data+'&amp;'+data1;

            $(this).blur();
            $.ajax({
                type: "POST",
                url: "c_insert.php",
                data: wholedata,
                cache: false,
                success:function(html){
                    $('.class_all'+id).append(html);
                }
            });
            return false;
        }
    });
});
</code></pre>
