Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.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
通过jquery检索表数据_Jquery - Fatal编程技术网

通过jquery检索表数据

通过jquery检索表数据,jquery,Jquery,我在下面包含的changeStatus.jsp代码中有一个表。现在,我必须通过jquery函数清除所有表数据,该函数应该包含在后面的changeStatus.js代码中。请帮助解决问题 changeStatus.jsp: <table class="data" style="width: 100%" id="${ns}changeStatusTable" style="table-layout:fixed; word-wrap: break-word">

我在下面包含的
changeStatus.jsp
代码中有一个表。现在,我必须通过jquery函数清除所有表数据,该函数应该包含在后面的
changeStatus.js
代码中。请帮助解决问题

changeStatus.jsp:

 <table  class="data"   style="width: 100%" id="${ns}changeStatusTable" style="table-layout:fixed; word-wrap: break-word">
                <thead>
                  <tr>
                     <th style="width: 10%">Cable</th>
                     <th style="width: 7%">Pair</th>
                     <th  style="width: 25%">Defective Code</th>
                     <th  style="width: *">Remarks</th>
                     <logic:equal name="ChangeStatusBean" property="rowError" value="false">
                         <th  style="width: 30%">Error Message</th>
                     </logic:equal>
                  </tr>
                </thead>

                <tbody> 
                  <logic:iterate id="rowData" indexId="idx" name="ChangeStatusBean"
                        property="rowData">
                      <tr style="width: 100%">
                        <td style="width: 10%" id=cable" ><html:text value="" styleId="${ns}cable1" property="cable"  maxlength="10" style="width:10em" /></td>
                        <td style="width: 7%" id="pair"><html:text value=""  styleId="${ns}pair1" property="pair" maxlength="4" style="width:7em"/></td>
                        <td style="width: 25%" id="code"><html:select styleId="${ns}defectiveCode"  name="ChangeStatusBean" 
                            property="defectiveCode"  style="width:275px" >
                                 <html:option value="">Select</html:option>
                                 <html:optionsCollection property="defectiveCodeList" label="value" value="value" />
                             </html:select></td>
                        <td style="width: *" id="remarks"><html:text value=""  styleId="${ns}remark" property="remark"  style="width:275px"  maxlength="14"/></td>
                        <logic:equal name="ChangeStatusBean" property="rowError" value="false">
                            <td style="width: 30%" id="errorMessage"><html:text value=""  styleId="${ns}errorMsg" property="errorMessage" style="width:275px" /></td>
                        </logic:equal>
                      </tr>
                  </logic:iterate>               
                </tbody>
              </table>

电缆
一对
缺陷代码
评论
错误消息

您只需执行以下操作即可清除表中的所有内容:

$('#table_id td').text('');
其中,上面的
表\u id
是实际id

如果您只想清除某些单元格(这显然是您正在尝试的),那么可以使用更具体的选择器。例如:

$('#table_id td.cable').text('');
这里有一个JSFIDLE:

$(table).empty()
如果这不是您想要的,那么我想您应该更清楚地了解您想要实现的目标。
$('#table_id td.cable').text('');