这是很简单的JavaScript调用:获取段落的ID内CKEDITOR 4
CKEDITOR.instances.yourEditorInstance.getData()
返回:
<p id="rand_dom_123">Python A B C</p>
<p id="rand_dom_852">PHP A B C D E F</p>
但是:
CKEDITOR.instances.yourEditorInstance.editable().getText()
返回:
Python A B C
PHP A B C D E F
这是我的代码:
$('.jquery_ckeditor').ckeditor(config);
CKEDITOR.instances['editor'].on('blur', function() {
var html_content = CKEDITOR.instances['editor'].getSelection().getSelectedText() ;
alert(html_content);
});
我怎样才能得到所选段落的ID
?例如,我可以知道它的段落编号,如果我选择A B C
问题是我想获取选定段落的ID。 – kn3l
@BandOfBrothers使用范围 – giammin
var html_content = CKEDITOR.instances ['editor']。getSelection()。getRanges()。createIterator(); \t \t \t id = html_content.getAttribute('id'); \t \t \t alert(id);不起作用。 – kn3l