执行任务后绑定?

Bind after performing task?

delay() 似乎没有做这件事。用户点击一个 .tab 后,应该禁止点击任何其他 .tab,并且在这些东西完成后,应该再次启用点击。

$('.tab').on('click', function() {
    //disable user clicks while performing the stuff below
    $('.tab').unbind();
    //stuff going on here
    //enable clicking again
    $('.tab').delay( 500 ).bind();     
});

当您调用 $('.tab').unbind(); 时,您会 删除附加到元素的所有处理程序 不会禁用该事件。

bind需要提供新的事件处理程序。 http://api.jquery.com/bind/

$('.tab').css("pointer-events", "none");

$('.tab').css("pointer-events", "auto");

而不是绑定

文档说:

The .delay() method is best for delaying between queued jQuery effects. Because it is limited—it doesn't, for example, offer a way to cancel the delay—.delay() is not a replacement for JavaScript's native setTimeout function, which may be more appropriate for certain use cases.

delay 应该延迟 jQuerys fx 队列中与动画和效果相关的项目的执行。

为了其他目的,您应该使用setTimeout。由于您已经在使用 on,因此您应该使用 off 并坚持使用 on 而不是将其与 bind.

混合使用

$('.tab').on('click', function handler() {
  //----------------------------^ for re-use
  //disable user clicks while performing the stuff below
  $('.tab').off();
  //stuff going on here
  //enable clicking again
  console.log('test');
  setTimeout(function() {
    $('.tab').on('click', handler);
  }, 5000);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="tab">test</div>