Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think that what you want to do is something like this (<a href="http://jsfiddle.net/ynxKG/" rel="nofollow">example for JQuery 1.7.2</a>):</p> <pre><code>$("#a").hover(function(){alert("test")}); $("#a")[0].active=true; $("#b").click(function(){ if($("#a")[0].active){ $("#a")[0].storedEvents = []; var hoverEvents = $("#a").data("events").mouseover; jQuery.each(hoverEvents , function(key,handlerObj) { $("#a")[0].storedEvents.push(handlerObj.handler); }); $("#a").off('hover'); }else{ for(var i=0;i&lt;$("#a")[0].storedEvents.length;i++){ $("#a").hover($("#a")[0].storedEvents[i]); } } $("#a")[0].active = ($("#a")[0].active)==false; });​ </code></pre> <p><a href="http://jsfiddle.net/ynxKG/" rel="nofollow">JSFiddle Example</a></p> <p>But there are a couple of things that you must have in consideration:</p> <ul> <li>This will only work if you add the events with JQuery, because JQuery keeps an internal track of the event handlers that have been added.</li> <li>Each version of JQuery handles <code>data("events")</code> differently, that means that this code may not work with other version of JQuery.</li> </ul> <p>I hope that this helps.</p> <p><strong>EDIT:</strong></p> <p><code>data("events")</code> was an internal undocumented data structure used in JQuery 1.6 and JQUery 1.7, but <a href="http://blog.jquery.com/2012/08/09/jquery-1-8-released/" rel="nofollow">it has been removed in JQuery 1.8</a>. So in JQuery 1.8 the only way to access the events data is through: <code>$._data(element, "events")</code>. But keep in mind the advice from the JQuery documentation: <strong>this is not a supported public interface; the actual data structures may change incompatibly from version to version</strong>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload