Sto provando a usare inarray ma è sempre vero che restituisce vero? Qualche idea? (Tutte Li stanno mostrando)jQuery .inArray() sempre vero?
$("#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? ora nessuno di loro sta mostrando? –
ecco l'elenco di selezione ... Blackberry –
@Charles: questo perché la matrice' arrVals' non contiene ''Army'' o'' Aqua'', ma contiene invece un oggetto dove sia la 'chiave' o' valore' (non sono sicuro quale) ha la stringa che si desidera. – user113716