我已经在 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>
在下图中,假设 Row1 和 col 1 ,是否可以在 javascript 或 html 中使其以黄色闪烁/闪烁?谢谢
更新 我能够闪烁单元格,但目前所有单元格都随机闪烁,尽管我有同样的时间。但我希望它们全部一起闪烁(同时)并熄灭,然后再次闪烁并熄灭
最佳答案
您可以创建一个 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);
关于javascript - 在一段时间内切换(或闪烁)表中的特定单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9615828/