SO jQuery Fiddle

Test Fiddle mainly for SO Questions jQuery 1.4.3, UI 1.8.5

by Nick Craver

HTML

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/ui-lightness/jquery-ui.css">
<button class="reply">Reply</button>
<div class="commentbox">
    <textarea></textarea>
</div>

JavaScript

var comment = function(){
    this.textarea = null;
    var self = this;
    $(document).ready( init );
    
    function init()
    {
        $('.reply').click( reply_to );
        self.textarea = $('.commentbox textarea');
    }
    
    function set_text( the_text )
    {
        self.textarea.val( the_text );
    }
    
    function reply_to() {
      set_text( 'a test text' );      // properly gets called.
    }
}();