Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/429.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript显示来自多个select的多个表行_Javascript_Multiple Select - Fatal编程技术网

Javascript显示来自多个select的多个表行

Javascript显示来自多个select的多个表行,javascript,multiple-select,Javascript,Multiple Select,我希望我的代码根据用户在多个选择项中选择的内容显示多个表行。由于某种原因,我的代码只显示最后选择的项目,有人能帮我吗?我的代码是: if(List[x].selected) { $('table#newspaper-a tr:not(#header, #trWeekNummer)').hide(); $('table#newspaper-a tr:not(#header, #trWeekNummer)').each(function(){

我希望我的代码根据用户在多个选择项中选择的内容显示多个表行。由于某种原因,我的代码只显示最后选择的项目,有人能帮我吗?我的代码是:

if(List[x].selected)
{               
    $('table#newspaper-a tr:not(#header, #trWeekNummer)').hide();
    $('table#newspaper-a tr:not(#header, #trWeekNummer)').each(function(){      
        $('td:nth-child(1)',this).each(function(){  
            if($(this).text() == List[x].value)
                $(this).parent(this).show();
        });
    });     
}

我自己解决了这个问题,解决方案是:

$('table#newspaper-a tr:not(#header, #trWeekNummer)').hide();

if(List[x].selected)
{               
$('table#newspaper-a tr:not(#header, #trWeekNummer)').each(function(){      
    $('td:nth-child(1)',this).each(function(){  
        if($(this).text() == List[x].value)
            $(this).parent(this).show();
    });
});     

}

你能为这个做一把小提琴吗?我怎么做小提琴?对不起,我是新来的:)你可以去jsfiddle.net。将js、html和css粘贴到相关列中,然后点击save。我很想这样做,但是里面有太多的数据库连接,所以我要在里面放一个精简版本。这是一个非常精简的版本的真正的表,但我希望你得到的想法。