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>
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?
Sure.
document.getElementById('someSpan').onmouseover =
function() {
this.className='newactive';
};
The safe way is to use a Javascript toolkit like Prototype or JQuery.
They all can do things like this easily but it works cross-browser.
For example, here is how you do it in JQuery.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With