I had to solve this problem myself today, too. I found that the mousedown event fires before the blur event, so all you need to do is set a variable that indicates that a mousedown event occurred first, and then manage your blur event appropriately if so.var mousedownHappened = false;$('input').blur(function() { if(mousedownHappened) // cancel the blur event { alert('stay focused!'); $('input').focus(); mousedownHappened = false; } else // blur event is okay { // Do stuff... }});$('a').mousedown(function() { mousedownHappened = true;});希望这对您有帮助! 这篇关于单击jQuery中的链接时如何防止blur()运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-15 11:58