<br/>标签会自动添加到ckeditor中的html标签中

har*_*rry 5 javascript ckeditor html-editor

每当我通过CKEditor添加HTML内容时,它会自动在每个其他html标记的末尾附加一个"br"标记.

我该如何删除它?

CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR;
CKEDITOR.config.shiftEnterMode = CKEDITOR.ENTER_P;
CKEDITOR.replace(elemId,
{
    resize_enabled: false,
    entities: false,
    basicEntities: false,
    entities_greek: false,
    entities_latin: false,
}
Run Code Online (Sandbox Code Playgroud)

Bil*_*nks 0

如果您以字符串形式获取 html,则只需运行 .replace('','') 即可。如果您担心要保留的 br 标记,则只需将它们替换为在解析字符串之前从未使用过的随机符号即可。