Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.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 返回匹配项的数组_Javascript_Jquery - Fatal编程技术网

Javascript 返回匹配项的数组

Javascript 返回匹配项的数组,javascript,jquery,Javascript,Jquery,我已经准备好了,你会看到这张桌子: <table class="col-md-6 table" id="prof-table"> <tbody><tr> <th>HORÁRIO</th> <th data-dia="seg">Segunda-Feira</th>

我已经准备好了,你会看到这张桌子:

<table class="col-md-6 table" id="prof-table">
                <tbody><tr>
                    <th>HORÁRIO</th>
                    <th data-dia="seg">Segunda-Feira</th>
                    <th data-dia="ter">Terça-Feira</th>
                    <th data-dia="qua">Quarta-Feira</th>
                    <th data-dia="qui">Quinta-Feira</th>
                    <th data-dia="sex">Sexta-Feira</th>                 
                </tr>
                <tr>
                    <td>08:30 ~ 10:30</td>
                <td>
                   <ol>
                     <li data-prof="3">Lab I</li>
                   </ol>
                </td>
                </tr>
                <tr>
                    <td>10:30 ~ 12:30</td>
                <td>
                </td>
                <td>
                   <ol>
                      <li data-prof="3">Lab II</li>
                   </ol>
                </td>
                </tr>
                <tr>
                    <td>14:30 ~ 16:30</td>
                </tr>
                <tr>
                    <td>16:30 ~ 18:30</td>
                </tr>
                <tr>
                    <td>18:30 ~ 20:30</td>
                </tr>
                <tr>
                    <td>20:30 ~ 21:30</td>
                </tr>
                <tr>
                    <td>21:30 ~ 23:30</td>
                </tr>
            </tbody></table>
我需要得到一个数组/集合,其中包含一个特定的

var $items = $(myRow).find('ol > li');                                  
   $.each($items, function(){
      if($(this).text() == disciplina){
         if($(this).data('prof') != professor_id){
            $(myRow).find('td > ol').append("<li data-prof='"+professor_id+"'>"+            disciplina +"</li>");
      }
   }

});

但是$items为每个迭代返回一个元素,如果我希望一个数组同时包含所有元素,该怎么办?我该怎么做呢?

如果您知道可以使用的具体路线:

$("td > ol > li")
或更通用:

$("td").find("li")

所有td元素只包含一个li,因此我不清楚您的行为expecting@RoryMcCrossan这只是一个例子,会有不止一个。