How to prevent a double-click using jQuery?

前端 未结 15 790
孤街浪徒
孤街浪徒 2020-11-30 23:42

I have a button as such:


Within jQuery I am using the following, but it still

相关标签:
15条回答
  • 2020-12-01 00:42

    "Easy Peasy"

    $(function() {
         $('.targetClass').dblclick(false);
    });
    
    0 讨论(0)
  • 2020-12-01 00:43

    just put this method in your forms then it will handle double-click or more clicks in once. once request send it will not allow sending again and again request.

    <script type="text/javascript">
        $(document).ready(function(){
                $("form").submit(function() {
                    $(this).submit(function() {
                        return false;
                    });
                    return true;
                }); 
        }); 
    </script>
    

    it will help you for sure.

    0 讨论(0)
  • 2020-12-01 00:43

    What I found out was old but working solution on modern browsers. Works for not toggling classes on the double click.

    $('*').click(function(event) {
        if(!event.detail || event.detail==1){//activate on first click only to avoid hiding again on double clicks
            // Toggle classes and do functions here
            $(this).slideToggle();
        }
    });
    
    0 讨论(0)
提交回复
热议问题