我在使用 javascript 和 html 时遇到了一些麻烦。
这是我的脚本
<script type="text/javascript">
function flashtext(Urgent,col) {
var tmpColCheck = document.getElementById('Urgent').style.color;
if (tmpColCheck === 'silver') {
document.getElementById('Urgent').style.color = col;
} else {
document.getElementById('Urgent').style.color = 'silver';
}
}
setInterval(function() {
flashtext('flashingtext','red');
}, 500 ); //set an interval timer up to repeat the function
这是我的 HTML,
<div class="js-col-md-6 js-col-xs-6" id="<?php echo $ticket->priority ?>" style="text-align: center; background:<?php echo $ticket->prioritycolour; ?>;"><?php echo $ticket->priority; ?></div>
id 是从后端设置调用的 Urgent,这是我想要闪烁/闪烁的唯一一个。
这就是问题所在,它有效=D yaay!...但仅在第一个实例上,所有其他紧急实例都是可靠的。所以我正在寻找的是如何让所有实例闪烁/闪烁而不仅仅是第一个实例?
谢谢 :)