如何使用<td> <table> javascript/jquery清除标签的特定数据?



<!DOCTYPE html>
<html>
<head>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
	<title></title>
</head>
<body>
<table class="tapshil" id="" border="2px" width="100%">
   <thead>
      <tr>
         <th> <font face="preeti">l;=g+=</font></th>
         <th><font face="preeti"> k|=b=g</font></th>
         <th><font face="preeti"> ldlt</font></th>
         <th><font face="preeti"> eG;f/ dx;'n tyf hl/jfgf</font> </th>
         <th><font face="preeti"> cGtMz'Ns</font></th>
         <th><font face="preeti"> d"=c=s/ </font></th>
         <th><font face="preeti"> hDdf dx;'n</font> </th>
         <th><font face="preeti"> hDdf  </font> </th>
      </tr>
   </thead>
   <tbody>
      <!-- put loop here -->
      <tr>
         <td>1</td>
         <td>11   
            1212231
         </td>
         <td id="nameOfPeople">Arun Lama  2070-01-01 2072-01-01 Amin Shrestha  2070-01-01 2072-01-01
         </td>
         <td>3</td>
         <td>7</td>
         <td>11</td>
         <td>15</td>
         <td id="totalOfAll">36</td>
      </tr>
   </tbody>
</table>
</body>
</html>

我有一个<td id="nameOfPeople"></td>。我想使用其ID清除此特定的数据。因此,我试图清除数据,但尚未清除。我尝试过:

$(".tapshil tbody tr td .nameOfPeople").text('');

我试图清空数据,但没有清除字段。如何使其为空?

您期望在它的位置发生什么?该表无法回流以填补剩余的空间 - 这似乎是货车浏览器响应的配方。

考虑隐藏TD的内容,而不是TD本身。

您可以使用内联CSS隐藏:)

<td style="visibility:hidden"> Your content is hidden </td>

您也可以通过jQuery隐藏它。使用$("#td_id")。hide();

id在该表中必须是唯一的

$("#nameOfPeople").text('');

最新更新