Sélectionnez HTML
const showSelect = function(){
text = select.options[select.selectedIndex].textContent;
label.innerHTML = textVisible == select.value ?
`Opción seleccionada ${text} <br> NO tiene atributo "value" asignado` :
`Opción seleccionada "${text}" <br> SI tiene atributo "value" igual a "${select.value}"`;
};
const findValue = function(value){
result = -1;
let index = 0;
while(!result & index < select.options.length){
if(option.value == value) result = index;
index++;
}
return result;
}
const findText = function(value){
result = -1;
let index = 0;
while(!result & index < select.options.length){
if(option.textContaint == value) result = index;
index++;
}
return result;
}
const removeValue = function(value){
result = false;
index = findValue(value);
if(index){
select.remove(index);
result = true;
};
return result;
}
const removeText = function(value){
result = false;
index = findText(value);
if(index){
select.remove(index);
result = true;
};
return result;
};
showSelect();
select.addEventListener('change', function(){
showSelect();
});
Talented Tapir