jquery1.9 How to use the toggle function in the above version

Source: Internet
Author: User

The toggle () method is used to bind two or more event handler functions in response to the selected element's rotation click event.

However, this feature has been removed in versions 1.9 and older.

Feel this function is good, the following from the online collection, you can add the following code in JS, and then you can bind the element toggle function.

$.fn.toggle =function(FN, fn2) {varargs = Arguments,guid = Fn.guid | | $.guid++,i=0, Toggle=function(event) {varLasttoggle = ($._data ( This, "Lasttoggle" + fn.guid) | | 0)%i; $._data ( This, "Lasttoggle" + fn.guid, Lasttoggle + 1 );      Event.preventdefault (); returnargs[Lasttoggle].apply ( This, arguments) | |false;    }; Toggle.guid=GUID;  while(I <args.length) {args[i+ +].guid =GUID; }    return  This. Click (toggle); };

jquery1.9 How to use the toggle function in the above version

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.