Reputation: 91
I use a textarea with a wysiwyg class used from Simpla Admin from Themeforest (I don't know if this last is relevant).
<textarea name="message" id="targetText" class="wysiwyg">Hello</textarea>
I want to change "Hello" with "Test" with jQuery using:
$("#message").html("Test")
But now the whole wysiwyg object completely disappears and I see only "Test".
What can I do to keep the wysiwyg editor and get inside this editor the value "Test"?
Upvotes: 0
Views: 2477
Reputation: 4869
Since I don't have the WYSIWYG tool you are using so I cannot tell exactly, but I can tell you how to find !
You are probably using a javascript plugin that transform a textarea with the .wysiwyg
class and transform it so it appends the widget in it.
To find the real element that has your HTML content (that you want to change with your wysiwyg), use the Google Chrome Dev Tool by pressing F12 (or any dev Tool) and explore the HTML document to find what element is "really" containing the HTML content. And then, you can change the HTML directly like you did in your example, but with the right selector !
Hope it helped !
Upvotes: 1
Reputation: 12045
$("#targetText").val("Test");
or
$('textarea[name="message"]').val("Test");
or
$('.wysiwyg').val("Test");
Upvotes: 1