質問

I am using below code for iPad. But though an error message in IE 'Object not supported (addEventListener)'

function isTextInput(node) {
    return ['INPUT', 'TEXTAREA'].indexOf(node.nodeName) !== -1;
}
document.addEventListener('touchstart', function(e) { 
    if (!isTextInput(e.target) && isTextInput(document.activeElement)) {
    //document.activeElement.blur();
    $('input').blur();
}
}, false);
役に立ちましたか?

解決

The error is because addEventListener is supported only in IE9+, either you need to use attachEvent() or since you have jQuery use it

$(document).on('touchstart', function (e) {
    if (!isTextInput(e.target) && isTextInput(document.activeElement)) {
        //document.activeElement.blur();
        $('input').blur();
    }
});
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top