您可以使用单击按钮时将重置的超时。在下面的示例中,如果您在 5 秒内未单击按钮,则会显示文本。我将bind()函数更改为,on()因为第一个函数自 3.0 版以来已被弃用。//initial timeout initializervar timer = setTimeout(handler, 5000);//reset the timout onclick$('#clicker').on('click', () => { $('#text').hide(); window.clearTimeout(timer); timer = setTimeout(handler, 5000);});//hanlder function to show the text when the timeout is triggeredfunction handler() { $('#text').show();}<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><button id="clicker">Click me!</button><p id="text" style="display: none;">Please click me :(</p>