我的html是
<body>
<section class="section">
<textarea id="template">
<p style="text-align: center;">
<img title="TinyMCE Logo" src="//www.tinymce.com/images/glyph-tinymce@2x.png" alt="TinyMCE Logo" width="110" height="97" />
</p>
<h1 style="text-align: center;">Welcome to the TinyMCE editor demo!</h1></textarea>
</section>
<button class="btn">Click</button>
我的 JS 看起来像这样。
<script>
$(document).ready(function(){
var temp = ` <textarea id="template">
<p style="text-align: center;">
<img title="TinyMCE Logo" src="//www.tinymce.com/images/glyph-tinymce@2x.png" alt="TinyMCE Logo" width="110" height="97" />
</p>
<h1 style="text-align: center;">Welcome to the TinyMCE editor demo!</h1>
</textarea>`;
$(".btn").on("click",function(){
// $(".section").append($("#template").html());
$(".section").append(temp);
// $(".section").append(temp:String):tinymce.dom.DomQuery;
});
});
</script>
我的 TinyMce 代码
tinymce.init({
selector: "textarea",
plugins: [
"advlist autolink lists link image charmap print preview anchor",
"searchreplace visualblocks code",
"insertdatetime media table contextmenu paste"
],
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
});