【发布时间】:2016-02-09 06:39:05
【问题描述】:
我想在 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);
}
});
这对我不起作用。 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>
请提出一种获取 div Id 或在包含该按钮的 div 上插入类的方法。
【问题讨论】:
-
class: 'MyCoolBtn mycostom_class etc',? -
@madalin ivascu,感谢您的回复。我只是想确认“MyCoolBtn”是我要添加的 customClass。 TinyMCE JS 本身会在运行时附加预定义的类。添加 class: 'MyCoolBtn', 对我不起作用。
标签: javascript jquery html tinymce-4