I want to achieve the functionality that this editor has got with its preview feature tellsubway.

I have got this html:

    <textarea id="tbMsg" style="height:450px;width:100%;"></textarea>
I want whatever is in the textarea above to go onto this div, every 2 secs or so.

      <DIV id="preview" style="BORDER-RIGHT: #c0c0c0 1px solid; PADDING-RIGHT: 3px;
    BORDER-TOP: #c0c0c0 1px solid; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; BORDER-LEFT: #c0c0c0 1px solid; WIDTH: 660px;
    PADDING-TOP: 3px; BORDER-BOTTOM: #c0c0c0 1px solid; HEIGHT: 700px"></DIV>
I have this javascript/jquery:

    <script type="text/javascript">
   $(function() {
    $('#tbMsg').keyup( function() {
        alert(1);
        var text = $(this).val();
        $('#preview').html(text);
    });
});
    </script>
Alert 1 never happens, which means that the request wasnt successful. Where does my jquery goes wrong?