iPad Safari does not fire blur event

倖福魔咒の 提交于 2019-12-05 14:25:13

问题


I have an html input text element in my application with jQuery blur event handler:

$('#textBox').blur(function () { console.log('blur'); })

When I click on a page area out of the textbox, desktop browsers fire this event, but iPad Safari does not. And neither the keyboard nor the cursor does not disappear. Are there any ways to "enable" the blur event ?


回答1:


By design, a tap away will remove the hover state but the textbox will remain focused.

Safari Web Content Guide should help you develop for Safari on IOS devices.




回答2:


Workaround (albeit not recommended): https://codepen.io/kevinfarrugia/pen/rKpRBL

document.getElementById("container").addEventListener("click", () => {
  document.getElementById("container").focus();
});


来源:https://stackoverflow.com/questions/10914623/ipad-safari-does-not-fire-blur-event

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