在一段时间内切换(或闪烁)表中的特定单元格

2024-04-28

我已经在 Html 中创建了一个表格,我想让一个特定的单元格闪烁(打开和关闭)。您能否让我知道是否可以使用 javascript。

<html>
  <body>
    <h4>Two rows and three columns:</h4>
      <table border="1" width="100%" height="400" align="top">
        <tr style="height: 1">
          <td>
            <table width="100%" border="2" height ="100" align="top">
              <tr>
                 <td  bgcolor="#FFFF00">1-1</td> <!-- R1C1 Yellow -->
                 <td>1-2</td> 
               </tr>
               <tr>
                 <td>1-3</td>
                 <td>1-4</td>
               </tr>
             </table>
          </td> 
          <td>
            <table width="100%" border="2" height ="100" align="top">
               <tr>
                 <td>2-1</td>
                 <td>2-2</td> 
               </tr>
               <tr>
                 <td>2-3</td>
                 <td>2-4</td>
               </tr>
             </table>
          <td>
            <table width="100%" border="2" height ="100" align="top">
               <tr>
                 <td>3-1</td>
                 <td>3-2</td> 
               </tr>
               <tr>
                 <td>3-3</td>
                 <td>3-4</td>
               </tr>
           </table>
         </td> 
       </tr>
       <tr style="vertical-align: top">
         <td>
           <table width="100%" border="2" height ="100">
               <tr>
                 <td>4-1</td>
                 <td>4-2</td> 
               </tr>
               <tr>
                 <td>4-3</td>
                 <td>4-4</td>
               </tr>
          </table>
         <td>
           <table width="100%" border="2" height ="100">
               <tr>
                 <td>5-1</td>
                 <td>5-2</td> 
               </tr>
               <tr>
                 <td>5-3</td>
                 <td>5-4</td>
               </tr>
             </table>
          <td> 
             <table width="100%" border="2" height ="100">
               <tr>
                 <td>6-1</td>
                 <td>6-2</td> 
               </tr>
               <tr>
                 <td>6-3</td>
                 <td>6-4</td>
               </tr>
             </table>
          </td>
        </tr>
    </table>
  </body>
</html>

In the below image , say Row1 and col 1 , Is it possible in javascript or html to make it flash/blink in yellow? Thanks image file

UPDATE我能够闪烁单元格,但目前所有单元格都随机闪烁,尽管我有同样的时间。但我希望它们全部一起闪烁(同时)并熄灭,然后再次闪烁并熄灭


您可以创建一个 JavaScript 函数来更改所需单元格的背景颜色。 此外,您可以使用 setInterval() 函数在固定时间后调用该函数。

var flag = true;
function changeColor () {
    if(flag==true){
        document.getElementById("yourId").style.background="yourColor 1";
        flag=false;
    }
    else if (flag==false){
    document.getElementById("yourId").style.background="yourcolor 2";
    flag = true;
    }
}
setInterval("changeColor()", timeinmillisec);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在一段时间内切换(或闪烁)表中的特定单元格 的相关文章

随机推荐