I am using select2 which generates your selection and I have this, and I need to remove the 'x' from span:
This code prints the span element:
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();
});
In the chrome show me the console.log but does not hide it:
EVdn.k.fn.init [span.select2-selection__choice__remove, prevObject: EVdn.k.fn.init(1)] asociar:815 Span
