I have an HTML range that changes its onmouseover and onmouseout class:
<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 onmouseover and onmouseout events using a Javascript function called elsewhere on the page. Is it possible?
Of course.
document.getElementById('someSpan').onmouseover = function() { this.className='newactive'; };
A safe way is to use a Javascript toolkit like Prototype or JQuery.
All of them can do such things easily, but a cross browser works.
For example, here's how you do it in jQuery .
, jQuery , JavaScript, , :
document.getElementById( "elementId" ) onMouseOut = FunctionName;.
, jQuery 20 ( ), . - , , JavaScript.
, , onmouseover onmouseout Element , :
// Define your handler somewhere function myNewHandler() { // ...new logic... } // And where you want to swap it in: document.getElementById('someSpan').onmouseover = myNewHandler;
... . addEventListener attachEvent ( , IE) . , Prototype, jQuery , .
:
document.getElementById("someSpan").onmouseover = function() { //New code };//Do not forget the semicolon
Source: https://habr.com/ru/post/1715329/More articles:Classic ASP in 64-bit mode and .NET COM DLL - .netAny efficient way to read data from a large binary? - pythonFormatting numbers is right-aligned while keeping the currency symbol left-aligned - asp.netReporting Services 2008 on Sql Server 2005 - sql-serverhow to send SMS / E-mail from the application - emailcall the boulder validator in the MultiActionController ModelAndView method ... maybe? as? - javabit.ly - API Stat Tracking - urlConvert Double to Integer for GetHashCode in Delphi - doublePrinting PRN Files from C # - c #Hi load balanced load server using WCF and MSMQ - c #All Articles