我在Froala编辑器中添加了一个自定义按钮。
$.FroalaEditor.DefineIcon('yt', {NAME: 'plus'});
$.FroalaEditor.RegisterCommand('yt', {
title: 'make yt',
focus: true,
undo: true,
refreshAfterCallback: true,
callback: function () {
console.log(this);
}
});
当我点击按钮时, console.log(this)显示
b {id: 1, opts: {…}, sid: 1, shared: {…}, $oel: m.fn.init(1), …}
$box:m.fn.init [div#jobEditor.fr-box.fr-basic.fr-top, context: div#jobEditor.fr-box.fr-basic.fr-top]
$doc:m.fn.init [document, context: document]
$el:m.fn.init [div.fr-element.fr-view]
$oel:m.fn.init [div#jobEditor.fr-box.fr-basic.fr-top, context: di...
(more stuff)
我看到了我想要的DIV的ID(#jobEditor)。 如何从“this”中提取它?
答案 0 :(得分:1)
this.$box.prop('id')
或
this.$box[0].id