如何使用Javascript更改onmouseover事件? [英] How do I change an onmouseover event using Javascript?

查看:74
本文介绍了如何使用Javascript更改onmouseover事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML版本,它改变了它的类onmouseover和onmouseout:

I have an HTML span which changes it's class onmouseover and onmouseout:

<span id="someSpan" class="static" onmouseover="this.className='active'" onmouseout="this.className='static'">Some Text</span>

我希望能够使用Javascript函数启用和禁用(更改)onmouseover和onmouseout事件在页面的其他地方调用。这可能吗?

I want to be able to enable and disable (change) the onmouseover and onmouseout events using a Javascript function called elsewhere on the page. Is this Possible?

推荐答案

当然。

document.getElementById('someSpan').onmouseover = 
     function() { 
         this.className='newactive'; 
     };

这篇关于如何使用Javascript更改onmouseover事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆