这对我有用。,创建一个 div 标签,里面放你的textarea元素
<div id="CommentTextArea">
<textarea name="comment_text" id="comment" rows="9" cols="50" ></textarea>
</div>
<button type="submit" id="send"> Send </button>
在您的 .js 文件中
$(function(){
// Initialize the Editor
$("#comment").wysihtml5({
toolbar: {
"size": "xs", //<buttonsize> // options are xs, sm, lg
"font-styles": false, // Font styling, e.g. h1, h2, etc.
"emphasis": true, // Italics, bold, etc.
"lists": false, // (Un)ordered lists, e.g. Bullets, Numbers.
"html": false, // Button which allows you to edit the generated HTML.
"link": true, // Button to insert a link.
"image": true, // Button to insert an image.
"color": false, // Button to change color of font
"blockquote": false, // Blockquote
}
});
// when the send button is clicked
$('#send').click(function(){
setTimeout(function(){
//remove wysihtml5Editor contents
$("#CommentTextArea").html('<textarea name="comment_text" id="comment" rows="9" cols="50" ></textarea>');
// and then Initialize the Editor again,
$("#comment").wysihtml5({
toolbar: {
"size": "xs", //<buttonsize> // options are xs, sm, lg
"font-styles": false, // Font styling, e.g. h1, h2, etc.
"emphasis": true, // Italics, bold, etc.
"lists": false, // (Un)ordered lists, e.g. Bullets, Numbers.
"html": false, // Button which allows you to edit the generated HTML.
"link": true, // Button to insert a link.
"image": true, // Button to insert an image.
"color": false, // Button to change color of font
"blockquote": false, // Blockquote
}});
}, 1000);
});
});