[英]JQuery focus and click running on same time on element
我有一個具有2種不同行為的按鈕
情況1運行正常,但是當我們按Enter鍵時,焦點移至Button 2,然后移至Button 1,在這里我發現當我們按Enter鍵時也調用了模糊,因此它調用了關注功能,有什么方法可以實現我的目標?
$('#btn').on('focus', function(){
}).on('blur', function(){
setTimeout(function() {
$('.span-hlo')[0].focus();
},250);
});
$('#btn').on('click', function(){
setTimeout(function() {
$('.span-welcome')[0].focus();
},250);
});
像這樣更新你的jquery
var lastClick = null;
$('#btn').mousedown(function(e) {
lastClick = e.target;
}).focus(function(e){
if (e.target == lastClick) {
$('.span-welcome')[0].focus();
} else {
$('.span-hlo')[0].focus();
}
lastClick = null;
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.