我通过这个jquery调用获得了#内容字段html:
jQuery("#content").html()
这似乎在“添加新帖子”页面上失败了。有关于如何获取#content div内容的提示吗?干杯
我通过这个jquery调用获得了#内容字段html:
jQuery("#content").html()
这似乎在“添加新帖子”页面上失败了。有关于如何获取#content div内容的提示吗?干杯
部门#editorcontainer
包含常规文本区域#content
和iframe#content_ifr
.
这个#content
加载页面时,将填充帖子的保存内容。这意味着调用时不会返回对内容的任何实时编辑jQuery("#content").html()
. 出于同样的原因,对于新帖子,您会得到一个空字符串。
您真正需要查找实时更新内容的地方是iframe,它由WYSIWYG编辑器使用。方法如下:
jQuery(\'#content_ifr\').contents().find(\'#tinymce\').html();
另请参见:jquery/javascript: accessing contents of an iframe.我的代码在以下表单中运行良好:
tinyMCE.triggerSave();
txt = $(\'#myTextarea\')
.contents()
.find(\'#tinymce\')
.html()
.replace(\'<br data-mce-bogus="1">\', \'\')
;
if (console && console.log) console.log(txt);
我知道我可以使用以下代码向wordpress的页脚添加一个需要jquery的脚本文件:<?php function my_scripts_method() { // register your script location, dependencies and version wp_register_script(\'custom_script\', get_template_directory_uri() . \'/js/custom_sc