jQuery 获取WordPress编辑器 wp_editor 中的内容
// jQuery form提交时候,无法直接获取到富文本编辑器中的内容,通过此方法获取内容并赋值,以实现ajax提交
if ($(".wp-editor-area").length > 0) {
var wp_editor_id = $(".wp-editor-area").attr('id');
var content;
var editor = tinyMCE.get(wp_editor_id);
if (editor) {
content = editor.getContent();
} else {
content = $('#' + wp_editor_id).val();
}
$("#" + wp_editor_id).val(content);
}
撰写评论