首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >jQuery .inArray()总是真的吗?

jQuery .inArray()总是真的吗?
EN

Stack Overflow用户
提问于 2010-12-30 05:39:23
回答 1查看 24.4K关注 0票数 19

我尝试使用inarray,但它总是返回true?有什么想法吗?(所有的li都显示出来了)

$("#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();
    };
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4558086

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档