我无法捕获Select2事件-我怀疑我使用了错误的jquery选择器

问题描述

这是我编写的JavaScript,它提醒我找到了四个.select2实例和四个select元素,并将消息记录到控制台,但没有任何改变从select2框中选择的内容实际上是在记录日志或向我发出有关更改的警报。我怀疑我使用了错误的选择器来找到将这些change侦听器附加到的对象,但是我无法在文档中找到有关如何找到我的select2元素的完整示例。>

$(document).on('change','.select2-input',function(e) {
    console.log('Detected a different change!');
    alert('The other method of detecting changes worked!');
});
$('.select2').on('change',function(e) {
    console.log('Detected a change!');
    alert('Something was changed!');
});
console.log('Loaded!');
alert('Loaded v2 - found ' + $('.select2').length + ' instances of select2 and ' + $('select').length + ' instances of select.');

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)