Problem - On my html page there's one textarea. Code is -
<div id ="textFields" class="form-group">
<p align="center">
<br>
<textarea placeholder="Enter note, max limit 200 words" class="form-control" rows="5" id="note" style="width: 80%;overflow:auto;"></textarea>
<script>CKEDITOR.replace( 'note' );</script>
</p>
</div>
Now I want to create multiple textareas, for which I'm using an Add button and the jQuery code -
$(document).ready(function(){
$("#addNew").click(function () {
var inputField = jQuery('<p align="center"><br><textarea placeholder="Enter note, max limit 200 words" class="form-control" rows="5" id="note" style="width: 80%;overflow:auto;"></textarea><script>CKEDITOR.replace( 'note' );</script></p>');
jQuery('#textFields').append(inputField);
}); });
When I click the #addNew button, the textarea is created but the CKEditor script is not loaded. This results in a plain textarea without CKEditor's functionalities.
How do I create a new textarea with CKEditor functionalities? Is there another way? Is my approach wrong?
<textarea>tag and the call toCKEDITOR.replace. Also don't add the<script>tag when creating the jQuery object, just call the function after appending the textarea element.