获取当前froala编辑器的ID

时间:2018-02-14 20:57:04

标签: javascript jquery froala

我在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”中提取它?

1 个答案:

答案 0 :(得分:1)

this.$box.prop('id')

this.$box[0].id

相关问题