简体   繁体   English

jQuery两次单击运行功能

[英]jQuery on click run functions inside twice

Is it possible to run all functions twice on click function? 单击功能是否可以两次运行所有功能?

Example: 例:

$('a').click(function(){
    function1();
    function2();
});

This should run function1(); function2(); 这应该运行function1(); function2(); function1(); function2(); and again function1(); function2(); 再次function1(); function2(); function1(); function2();

Try to bind events twice and if you want to run that function more than twice then the most preferred way is looping. 尝试将事件绑定两次,如果您想运行该函数两次以上,则最优选的方法是循环。

function twice(){
    function1();
    function2();
}

$('a').click(twice).click(twice);

DEMO DEMO

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM