Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/475.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.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 无法在jquery中的表内选择表_Javascript_Jquery_Html - Fatal编程技术网

Javascript 无法在jquery中的表内选择表

Javascript 无法在jquery中的表内选择表,javascript,jquery,html,Javascript,Jquery,Html,我目前在使用jquery选择表中的表时遇到问题,我想选择表中的第二个表,如下面的HTML代码所示。我尝试了下面的jquery代码,但是当我使用它时,会将第一个tr添加到style=“display:none;”“,因为我在下面写下它来显示它选择的tr,但我想选择第三个表tr。谁能帮我选择正确的表格 以下是我尝试过的: <script> $(document).ready(function () { $("table td:contains('NIL')").close

我目前在使用jquery选择表中的表时遇到问题,我想选择表中的第二个表,如下面的HTML代码所示。我尝试了下面的jquery代码,但是当我使用它时,会将第一个
tr
添加到
style=“display:none;”“
,因为我在下面写下它来显示它选择的
tr
,但我想选择第三个
表tr
。谁能帮我选择正确的
表格

以下是我尝试过的:

    <script>
    $(document).ready(function () {
$("table td:contains('NIL')").closest("tr").hide();
});
    </script>

         <table width="79%" border="0" cellpadding="0" cellspacing="0" height="350">
              <tr style="display:none;">
                    <td valign="top" width="1%" bgcolor=#FFFFFF>
                        &nbsp;
                    </td>
                    <td valign="top" width="78%" bgcolor=#FFFFFF>



                    <center>
                    <br><b><u>COURSE PAGE - Winter Semester 2015~16</u></b><br /><br />



                    <table cellspacing='0' cellpadding='4' align='center' border='1' width='95%' style='border-collapse: collapse;' bordercolor='black'>

                        <tr align=center bgcolor=#5A768D>
                            <td width=80><font color=#FFFFFF>Course Owner</font></td>
                            <td width=70><font color=#FFFFFF>Course Code</font></td>
                            <td><font color=#FFFFFF>Course Title</font></td>
                            <td><font color=#FFFFFF>Course Type</font></td>
                            <td><font color=#FFFFFF>Faculty</font></td>
                            <td><font color=#FFFFFF>Class Nbr(s)</font></td>
                            <td><font color=#FFFFFF>Slot(s)</font></td>
                        </tr>
                        <tr bgcolor='#E1ECF2'>
                            <td width=80 align=center>SITE</td>
                            <td width=70 align=center>ITE302</td>
                            <td>Database Systems</td>
                            <td>Embedded Lab</td>
                            <td>11543 - SARAVANAKUMAR K - SITE</td>
                            <td>2039</td>
                            <td>L29+L30</td>
                        </tr>

                    </table><br>

                    <table cellspacing='0' cellpadding='4' width="95%" align='center' border='1' style='border-collapse: collapse;' bordercolor='black' height="61">
                    <tr>
                        <td bgcolor=#5A768D width="22%" height="30"><font color=#FFFFFF>Syllabus</font></td>
                        <form action='syllabus_file.asp' method='post'><td bgcolor='#EDEADE' width='75%' height='30'><input type='hidden' name='crscd' value='ITE302'><input type='hidden' name='crstp' value='ELA'><input type='hidden' name='version' value='1'><input type='submit' name='sybcmd' class='submit' value='Download'></td></form>
                    </tr>



                    <tr>
                        <td bgcolor=#5A768D width="22%" height="30" rowspan=5 valign=top>
                            <font color=#FFFFFF>Text/Reference Material</font>
                        </td>
                        <td bgcolor='#EDEADE' width="75%" height="30">
                            <a href='https://academics.vit.ac.in/faculty/Syllabus_Textbook/WINSEM2015-16_CP1673_TB01_DBMS_Lab_Manual.pdf' target='_blank'><font color=blue>DBMS_Lab_Manual.pdf</font></a>
                        </td>
                    </tr>

                    <tr>
                        <td bgcolor='#EDEADE' width="75%" height="30">
                            <a href='https://academics.vit.ac.in/faculty/Syllabus_Textbook/WINSEM2015-16_CP1673_TB02_Structured-Query-Language.pdf' target='_blank'><font color=blue>Structured-Query-Language.pdf</font></a>
                        </td>
                    </tr>

                    <tr>
                        <td bgcolor='#EDEADE' width="75%" height="30">
                            <a href='https://academics.vit.ac.in/faculty/Syllabus_Textbook/WINSEM2015-16_CP1673_TB03_students_manual.pdf' target='_blank'><font color=blue>students_manual.pdf</font></a>
                        </td>
                    </tr>

                    <tr>
                        <td bgcolor='#EDEADE' width="75%" height="30">
                            NIL
                        </td>
                    </tr>

                    <tr>
                        <td bgcolor='#EDEADE' width="75%" height="30">
                            NIL
                        </td>
                    </tr>

                    </table><br>



                    <table cellspacing='0' cellpadding='4' width="95%" align='center' border='1' style='border-collapse: collapse;' bordercolor='black' height="61">

                    <tr>
                        <td bgcolor=#5A768D width="22%" height="30" rowspan=5 valign=top>
                            <font color=#FFFFFF>Assignments</font>
                        </td>
                        <td bgcolor='#EDEADE' width="76%" height="30">
                            NIL
                        </td>
                    </tr>

                    <tr>
                        <td bgcolor='#EDEADE' width="76%" height="30">
                            NIL
                        </td>
                    </tr>

                    <tr>
                        <td bgcolor='#EDEADE' width="76%" height="30">
                            NIL
                        </td>
                    </tr>

                    <tr>
                        <td bgcolor='#EDEADE' width="76%" height="30">
                            NIL
                        </td>
                    </tr>

                    <tr>
                        <td bgcolor='#EDEADE' width="76%" height="30">
                            NIL
                        </td>
                    </tr>

                    </table><br>

$(文档).ready(函数(){
$(“表td:contains('NIL'))。最近的(“tr”).hide();
});

课程页-2015~16冬季学期 球场老板 课程代码 课程名称 课程类型 官能 Nbr类(s) 插槽(s) 场地 ITE302 数据库系统 嵌入式实验室 11543-萨拉瓦纳库马尔K-现场 2039 L29+L30
教学大纲 文本/参考资料 无 无
作业 无 无 无 无 无

由于您的目标是
表的
td
内部
td
,因此需要指定
表的
内部
,如下所示:

$("table table td:contains('NIL')").closest("tr").hide();
或者准确地说,在
td
中的
如下所示:

$("table td table td:contains('NIL')").closest("tr").hide();
否则,您的条件将始终在一开始就满足,并且它将隐藏根
tr
,因为
td
内的
table
中存在
NIL

做个记录-我不明白您为什么添加了
display:none在第一个
tr
上,我已经删除了它


Sinppet

$(“表td:contains('NIL'))。最近的(“tr”).hide()


课程页-2015~16冬季学期

球场老板 课程代码 课程名称 课程类型 官能 Nbr类(s) 插槽(s) 场地 ITE302 数据库系统 嵌入式实验室 11543-萨拉瓦纳库马尔K-现场 2039 L29+L30
教学大纲 文本/参考资料 无 无
作业 无 无 无 无 无

你的
标签在哪里?拜托,我知道我已经添加了。它没有添加到你的代码中!!!具体点。现在似乎没有
$(document).ready()
…很抱歉添加了这个。因为
第三个表
中的所有
td
都有
NIL
,没有一个
tr
会显示出来,这基本上意味着整个
都会显示出来