Copy the textarea value to another textarea

Copying the textarea 1's value into another text area based on the checkbox selected.

by Varun Krishna P

HTML

<textarea name="" id="te1" cols="30" rows="10"></textarea>
<textarea name="" id="te2" cols="30" rows="10"></textarea>
<input type="checkbox" class="cb1">

JavaScript

$(function(){
   $(".cb1").click(function(){
       alert("hello");
        if($(this).prop("checked")){
            $("#te2").val($("#te1").val());
        }
    });
});