【问题标题】:Select all inputs, except elements inside Summernote's div选择所有输入,除了 Summernote 的 div 中的元素
【发布时间】:2018-04-29 16:25:44
【问题描述】:

Summernote 的模态具有内部输入的模态。

我的 JS 放在这里:

$('input, select, textarea').on('change',
    function(e){
        var inputs = $('input:text, input[type="radio"]:checked').map(
            function(){
                /* show values */
            }
        ).get();
    }
);

尝试使用not(),但不起作用:

var inputs = $('input:text, input[type="radio"]:checked')
    .not('div.note-editor > input')
    .map()
    .get();

【问题讨论】:

  • 如果你使用 ".not('div.form-group > input')" 代替,你的 ".not" 可能会起作用
  • 我不能使用它,因为表单组内也需要输入:(
  • 你也可以做 ".not('div.note-editor div.form-group > input.note-link-text')" 你可以根据你的需要来具体化
  • 是的,我可能会这样做,但是如果 Summernote 的输入没有包含在 .form-group 中怎么办?我真的不知道它有多少。

标签: javascript jquery html summernote


【解决方案1】:

使用not 是正确的,但您应该删除>,因为它指定了一个直接子代,而input 不是。所以

var inputs = $('input:text, input[type="radio"]:checked')
    .not('div.note-editor input')
    .map()
    .get();

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2012-05-20
  • 2012-05-18
  • 1970-01-01
  • 2023-03-13
  • 1970-01-01
  • 2017-02-07
  • 1970-01-01
  • 2020-11-28
相关资源
最近更新 更多