Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从编辑器获取特定内容_Php_Jquery_Ckeditor - Fatal编程技术网

Php 从编辑器获取特定内容

Php 从编辑器获取特定内容,php,jquery,ckeditor,Php,Jquery,Ckeditor,我有一个ckeditor,下面是我的ckeditor文本区,它的内容以及如何使用jquery仅获取中的内容 <textarea id="cheditor_text" name="cheditor_text" rows="10"> <p> welcome to our company </p> <p id="footer"> Copy right @ exak=mple.com </p> </textarea> 欢迎来到我

我有一个ckeditor,下面是我的ckeditor文本区,它的内容以及如何使用jquery仅获取

中的内容

<textarea id="cheditor_text" name="cheditor_text" rows="10">
<p> welcome to our company </p>
<p id="footer">
Copy right @ exak=mple.com
</p>
</textarea>

欢迎来到我们公司

复制右@exak=mple.com


你可以这样做

txt = $('#cheditor_text').text();
html = $('<div>').append(txt).find('#footer').prev()[0].outerHTML;
txt = $('#cheditor_text').text();
pTag = $('<div>').append(txt).find('#footer').prev();
alert($('<div>').append(pTag).html())​
txt=$('cheditor_text').text();
html=$('').append(txt).find('#footer').prev()[0].outerHTML;
不使用outHTML

txt = $('#cheditor_text').text();
html = $('<div>').append(txt).find('#footer').prev()[0].outerHTML;
txt = $('#cheditor_text').text();
pTag = $('<div>').append(txt).find('#footer').prev();
alert($('<div>').append(pTag).html())​
txt=$('cheditor_text').text();
pTag=$('').append(txt.find('#footer').prev();
警报($('').append(pTag.html())​
试试看

阅读此链接, 这很有帮助

试用


您甚至可以直接从编辑器中检索此元素的内容:

CKEDITOR.instances.your_editor_instance.document.getById( 'footer' ).getHtml();
然而,我认为你想做的事情的逻辑有问题。如果用户省略
id
属性或使用该属性两次,以这种方式检索内容可能会很危险。这是你不能依赖的


您最好创建两个编辑器,一个包含内容,另一个用于
#footer
。另一种可能性是在CKEditor 4中引入的,它允许按原样编辑网页。在我看来,你真的应该重新考虑你的想法,使它稳定可靠。

你提出的是一条艰难的道路,需要正则表达式提取页脚内容。