Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The way you intend to use the <a href="http://api.jquery.com/toggle/" rel="nofollow noreferrer"><code>.toggle()</code></a> function is <em>deprecated</em> since <strong>jQuery 1.8</strong> and has been <em>removed</em> in <strong>jQuery 1.9</strong>.</p> <p><a href="http://api.jquery.com/category/deprecated/deprecated-1.8/" rel="nofollow noreferrer">Category: Deprecated 1.8</a>:</p> <blockquote> <p>.toggle() Bind two or more handlers to the matched elements, to be executed on alternate clicks.</p> </blockquote> <p>This is reasoned in <a href="http://jquery.com/upgrade-guide/1.9/#toggle-function-function-removed" rel="nofollow noreferrer">Changes of Note in jQuery 1.9</a>:</p> <blockquote> <p>This is the "click an element to run the specified functions" signature of .toggle(). It should not be confused with the "change the visibility of an element" of .toggle() which is not deprecated. The former is being removed to reduce confusion and improve the potential for modularity in the library. The jQuery Migrate plugin can be used to restore the functionality.</p> </blockquote> <p>Nevertheless <a href="https://stackoverflow.com/users/128165/gaby-aka-g-petrioli">Gaby aka G. Petrioli</a> created a function that does the same as an answer to <a href="https://stackoverflow.com/q/14382857/1456376">What to use instead of <code>toggle(…)</code> in jQuery > 1.8?</a>:</p> <pre><code>$.fn.toggleClick = function(){ var methods = arguments, // store the passed arguments for future reference count = methods.length; // cache the number of methods //use return this to maintain jQuery chainability return this.each(function(i, item){ // for each element you bind to var index = 0; // create a local counter for that element $(item).click(function(){ // bind a click handler to that element return methods[index++ % count].apply(this,arguments); // that when called will apply the 'index'th method to that element // the index % count means that we constrain our iterator between 0 and (count-1) }); }); }; </code></pre> <p>You can simply use it like this:</p> <pre><code>$('selector').toggleClick(function1, function2, […]); </code></pre>
    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.
    3. VO
      singulars
      1. This table or related slice is empty.
    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