我有一个文本<info>SOME CONTENTS GOES HERE</info>
当我使用 javascript 函数单击按钮(自定义按钮)时,如何从编辑器中删除此文本。我使用了这段代码:
dom.remove(dom.getParent(selection.getNode(), 'info'));
但是显示错误。有什么解决办法吗?
提前致谢。
最佳答案
tinyMCE 在 DOMUtils 下提供了一个方法,它是 tinymce.dom.DOMUtils/remove
// Removes all paragraphs in the active editor
tinyMCE.activeEditor.dom.remove(tinyMCE.activeEditor.dom.select('p'));
// Removes a element by id in the document
tinyMCE.DOM.remove('mydiv');
所以在你的情况下,因为你想删除 <info>
以及里面有什么那么你应该写这样的东西:
// Removes all paragraphs in the active editor
tinyMCE.activeEditor.dom.remove(tinyMCE.activeEditor.dom.select('info'));
关于javascript - 使用javascript从tinymce编辑器中删除文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3988563/