I am using Jodit as text editor and I would like to delete a text within a textarea using jquery/javascript, but it seems I can not do it. I can read the textarea with $('#xxx').val(); but cannot write using e.g. $('#xxx').val('yyy');
I am adding some code hoping it will be more clear:
<form>
<textarea id="test">Hi</textarea>
</form>
<script>
$('textarea').each(function () {
var editor = new Jodit(this);
});
$('#test').val('Bye');
</script>
But the string in the textarea does not change. Also if try to delete it:
<script>
$('#test').val('');
</script>
Nothing happens.
You need to perform operation on editor object not directly on textarea.following example update text for jodit.
var editor = new Jodit('#editor');
editor.value = '<p>start</p>';
You can use this editor.value property to change text.
For your scenario below code will work
<form>
<textarea id="test">Hi</textarea>
</form>
<script>
var editor = = new Jodit('#test');
editor.value = 'any value here';
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With