The following script should insert the code that is set in an array into a specific div:
$(this).on("click", '[data-action="toggle-cat-edit"]', function() {
var catid = $(this).data("cate-id");
var editorHTML = [
"<div>",
"<p>hello</p>",
"</div>"
].join("\n");
$('#edit-category-tools-' + catid).editorHTML;
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="edit-category-tools-ID"></div>
I've tried through an alert: if the cate-id is set, the right div is gotten, and it works. But it doesn't include the array. Could someone help me on this? What have I done wrong?
Thanks in advance, I appreciate your effort.
.append(editorHTML)or.prepend(editorHTML)