Jquery 从select2中删除span

Jquery 从select2中删除span,jquery,jquery-select2,Jquery,Jquery Select2,我正在使用select2生成您的选择,我有这个 我需要从span中删除“x”: 此代码打印跨度元素: for (let i = 0; i < valores.length; i++) { const option = new Option(valores[i]['nombre'], valores[i]['nombre'], true, valoresLocalStorage.includes(valores[i]['nombre'])); valoresSelec

我正在使用select2生成您的选择,我有这个 我需要从span中删除“x”:

此代码打印跨度元素:

 for (let i = 0; i < valores.length; i++) {
     const option = new Option(valores[i]['nombre'], valores[i]['nombre'], true, valoresLocalStorage.includes(valores[i]['nombre']));
     valoresSelect.append(option).trigger('change');
 }

 valoresSelect.closest('[data-controller="fields--select"]').find('.select2-selection__choice').each(function () {
          console.log($(this).find('.select2-selection__choice__remove'));
          console.log('Span');

         $(this).find('.select2-selection__choice__remove').hide();
 });
for(设i=0;i
在chrome浏览器中,显示console.log但不隐藏它:

EVdn.k.fn.init[span.select2-selection\uuuuu choice\uuuu remove,prevObject: EVdn.k.fn.init(1)]协会:815 Span


您可以使用显示:无!重要的要隐藏select2下拉列表中的关闭按钮

演示代码

$(“#某物”)。选择2();
$('somethings').val([1',2']);
$('somethings')。触发器('change')
。选择2-选择\选择\删除{
显示:无!重要;
}

-塞莱克-
1.
2.
3.