Vous ne pouvez pas obtenir l'index de keyup, vous obtenez toujours l'index correspondant à la dernière classe
s'écrit à l'envers, ça devrait être $(this).index($(".select2-input"))
$(this).index($(".select2-input"))
s'écrit à l'envers, ça devrait être
![](http://img.php.cn/upload/image/000/000/000/fa3b7970faf780d670535d09b1cfc621-0.png)
$(this).index($(".select2-input"))