Rai*_*chu 3 html javascript jquery tinymce-4
我想在tinyMCE addButton()函数中的自定义按钮上添加自定义类.
例如
editor.addButton('keywords', {
text: 'Insert Keywords',
class: 'MyCoolBtn',
icon: false,
onclick: function () {
if($(this.id).hasClass("mce-active"))
EditorMethods.removeKeywordsToolbar(this.id);
else
EditorMethods.displayKeywordsToolbar(this.id);
}
});
Run Code Online (Sandbox Code Playgroud)
这对我不起作用.TinyMCE JS在包含按钮的div上添加了唯一的Id和一些类.我想在该div上添加我的自定义类以及其他类.
按钮的当前HTML是
<div aria-labelledby="mceu_35" tabindex="-1" class="mce-widget mce-btn mce-first mce-last mce-btn-has-text mce-active" id="mceu_35" role="button"> <button tabindex="-1" type="button" role="presentation"> <span class="mce-txt">Insert Keywords</span> </button> </div>Run Code Online (Sandbox Code Playgroud)
请建议一种获取div Id的方法,或者在包含该按钮的div上插入类.
小智 5
只需在它们之间写入带有空格的类名.
editor.addButton( 'ampforwp_tc_button', {
text: 'Copy The Content',
icon: 'dashicons dashicons-clipboard',
classes: 'ampforwp-copy-content-button ',
tooltip: 'Copy The Content from Main Editor',
onclick: function() {
editor.insertContent(tinymce.editors.content.getContent());
}
});
Run Code Online (Sandbox Code Playgroud)
但是它会在你给出的每个自定义类之前自动添加mce.所以要添加CSS使用类,如:
.mce-ampforwp-copy-content-button
Run Code Online (Sandbox Code Playgroud)
它肯定会像对待我一样解决问题.