Javascript/Jquery删除和添加'onmouseover'setinterval上的事件

Javascript/Jquery Remove and Add 'onmouseover' event on setinterval?

本文关键字:setinterval 事件 onmouseover 添加 Javascript Jquery 删除      更新时间:2023-09-26

我正在创建一个网页座位计划,我希望能够使区域标签每1或2秒闪烁一次,以便更容易地查看个人的座位。

唯一的问题是,我正在使用Mapper.js(http://www.netzgesta.de/mapper/)这是一个突出显示工具,但当我点击"区域"标签时,无法将此Mapper.js设置为闪烁。

我使用onmouseover事件来激活javascript函数来显示或突出显示区域标记。那么,有什么方法可以让区域标签闪烁吗?

下面的代码是我使用的:

<area class="noborder icolor000000 blink" coords="507, 3, 647, 161" href="#cp66" shape="rect" onmouseover="setAreaOver(document.getElementById('cp66'),'mapImage_canvas','0,0,0','0,0,0','0.33',0,0,0);null">

"onmouseover"是我试图每秒删除和添加的内容,以在设定的间隔内创建眨眼效果。我知道这是一种复杂的方法,但我认为没有其他方法。

如果可能的话,我需要这种眨眼效果才能在Internet Explorer 8中工作。代码用于显示高亮显示效果,但高亮显示一直保持,直到我将鼠标移出区域标记。

任何帮助或建议都将不胜感激,希望这能对我的努力有所帮助非常感谢

您可以尝试使用document.getElementById("youridhere").setAttribute("attributenamehere","value-here")

把它放在计时器中,让它以这种方式将属性更改为你想要的。

让我知道这是否适合你,或者你是否需要更多的细节。

您必须像这样使用setIntervalclearInterval

<script>
var area_timer = null;
function area_hover() {
    var hover = false;
    area_timer || (area_timer = setInterval(function() {
        if (hover = !hover) {
            // apply hover style here
        } else {
            // apply normal style here
        }
    }, 500));
}
function area_nohover() {
    clearInterval(area_timer);
    area_timer = null;
    // apply normal style here
}
</script>
<area onmouseover="area_hover()" onmouseout="area_nohover()" />