J'essaie d'utiliser inarray mais c'est toujours vrai? Des idées? (Tous de li montrent des)jQuery .inArray() toujours vrai?
$("#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? maintenant aucun d'eux ne montre? –
Voici la liste de sélection ... –
@Charles: Ceci est dû au fait que le tableau' arrVals' ne contient pas '' Army'' ou '' Aqua'', mais contient un objet où soit le 'key' ou' value' (pas sûr lequel) a la chaîne que vous voulez. – user113716