Why is blur event not fired in iOS Safari Mobile (iPhone / iPad)?

后端 未结 5 1241
感动是毒
感动是毒 2020-12-15 17:46

I\'ve two event handlers bound to an anchor tag: one for focus and blur.

The handlers fire on desktop, but in iphone and ipad only focus is fired correctly. Blur is

5条回答
  •  没有蜡笔的小新
    2020-12-15 18:45

    It's a hack, but you can get .blur to fire by registering a click handler on every DOM element. This removes focus from the previously focused element.

    $('*').click();
    $('html').css('-webkit-tap-highlight-color', 'rgba(0, 0, 0, 0)');
    

    The second line removes the highlight when elements are clicked.

    I know this is sub-optimal, but it may get you going.

提交回复
热议问题