Clear Textarea after Ajax Response while using clEditor

880 Views Asked by At

I am trying to clear value of text-area using cleditor. but its not clear after the ajax response. My code are below:

<link rel="stylesheet" href="cleditor/jquery.cleditor.css" />
<script src="cleditor/jquery.min.js"></script>
<script src="cleditor/jquery.cleditor.min.js"></script>
<script>$(document).ready(function () { $("#desc").cleditor(); });
</script>
//Ajax Response Function
success: function(response)
    {

        $("#btnSubmit").attr('value', 'Add');
        $("#frm_data")[0].reset();
        $("#Comman").show();
   }
<label class="col-sm-2 control-label">Description:</label>
    <div class="col-sm-10">
    <textarea rows="5" cols="5" name="desc" id="desc" class="form-control"> </textarea>
    </div>

Please let me know what can I do for clear the text area value on ajax response.

3

There are 3 best solutions below

6
On BEST ANSWER
$("#desc").cleditor()[0].clear();

http://jsfiddle.net/M2RS8/495/

4
On

You can clear the textarea field by assigning the empty value to textarea field. its work 100% for me, i hope its also work for you.

$('#desc').val('');
0
On

For this try something like $("#desc").val("");

$("#desc").val("");

Here #desc is the id of the textarea you want to clear and .val(' ') sets it's value to ' ' - notice the space between the ';