Fire Event before 'focus' kicks in / Fire Event before keyboard appears on iOS

我的未来我决定 提交于 2019-12-11 09:29:08

问题


I want to fire off an event before my focus on a textarea (i.e. before the keyboard appears on iOS).

Is this possible?

My code to handle the focus is here:

$(document).on('focus', 'textarea', function() {
    console.log("focus event");
});

回答1:


Try touchstart Event

$(document).on('touchstart', 'textarea', function() {
console.log("touchstart event");
  });



回答2:


I would use the focusin event note that this event catch the child elements focus as well.

focusin: sent before first target element receives focus

$("div").focusin(function(){
    $(this).css("background-color", "#FFFFCC");
}); 

Check here to know more about the focus events order



来源:https://stackoverflow.com/questions/24570852/fire-event-before-focus-kicks-in-fire-event-before-keyboard-appears-on-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!