Estoy tratando de usar inarray pero siempre es cierto? ¿Algunas ideas? (Todo de Li están mostrando)jQuery .inArray() siempre es cierto?
$("#select-by-color-list li").hide();
// get the select
var $dd = $('#product-variants-option-0');
if ($dd.length > 0) { // make sure we found the select we were looking for
// save the selected value
var selectedVal = $dd.val();
// get the options and loop through them
var $options = $('option', $dd);
var arrVals = [];
$options.each(function(){
// push each option value and text into an array
arrVals.push({
val: $(this).val(),
text: $(this).text()
});
});
};
//This is where it is returning true...
if($.inArray('Aqua', arrVals)) {
$("#select-by-color-list li#aqua").show();
};
if($.inArray('Army', arrVals)) {
$("#select-by-color-list li#army").show();
};
Hummm? ahora ninguno de ellos está mostrando? –
aquí está la lista de selección ... –
@Charles: Esto se debe a que la matriz' arrVals' no contiene ''Army'' or'' Aqua'', sino que contiene un objeto donde ya sea la 'clave' o 'valor' (no estoy seguro de cuál) tiene la cadena que desea. – user113716