gpt4 book ai didi

javascript - TinyMCE Editor - 如何通过 jQuery 访问自定义属性

转载 作者:行者123 更新时间:2023-12-03 12:11:07 25 4
gpt4 key购买 nike

我曾经有一个类名为“.dyskografia”的文本区域,我访问该类是为了将一些内容粘贴到其中。

以前是这样的:

$(this.el).find('.dyskografia').html("blah blah blah");

当我合并 TinyMCE 编辑器时,它弄乱了我的标签,现在我想这就是我应该引用的 - data-id="Dyskografia":

<body id="tinymce" class="mce-content-body " data-id="Dyskografia" contenteditable="true" spellcheck="false"><p>...</p></body>

如何更改之前的代码,将“blah blah blah”粘贴到带有 data-id="Dyskografia"的标签中?

最佳答案

您可以使用以下命令设置 TinyMCE 编辑器的内容:

// Sets the HTML contents of the activeEditor editor
tinyMCE.activeEditor.setContent('<span>some</span> html');

// Sets the raw contents of the activeEditor editor
tinyMCE.activeEditor.setContent('<span>some</span> html', {format : 'raw'});

// Sets the content of a specific editor (my_editor in this example)
tinyMCE.get('my_editor').setContent(data);

// Sets the bbcode contents of the activeEditor editor if the bbcode plugin was added
tinyMCE.activeEditor.setContent('[b]some[/b] html', {format : 'bbcode'});

如果您对更多信息感兴趣,可以阅读 documentation

关于javascript - TinyMCE Editor - 如何通过 jQuery 访问自定义属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24959291/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com