Jquery Toggle two function not work in 1.10.1

前端 未结 7 2018
执念已碎
执念已碎 2020-12-17 03:04

Jquery Toggle two function not work in jquery 1.10.1 but work\'s on Jquery 1.8.3

HTML

For example, consider the HTML:

7条回答
  •  情深已故
    2020-12-17 03:33

    Here is a generic method, with multiple functions to toggle:

    var toggleFunctions = [
        function () { /* do something */},
        function () { /* do something else */},
        ...
        function () { /* do some other stuff*/}
    ];
    
    $("#target").on("click", function(){
        // returns first function from array
        var currentFunction = toggleFunctions.shift(); 
        // executes the function
        currentFunction(); 
        // pushes current function to the back
        toggleFunctions [] = currentFunction; 
    });
    

提交回复
热议问题