简体   繁体   English

.blur()上的jQuery .hide()在iOS Web应用程序中不起作用

[英]jQuery .hide() on .blur() not working in iOS web app

I have a web app which hides the bottom toolbar while typing to stop it going on top of the keyboard. 我有一个网络应用程序,可在键入时隐藏底部的工具栏以使其停止在键盘上方。

$(document).ready( function() {
    $("#open").focus( function() {
        $('#bottom').hide();
    });
    $("#open").blur( function() {
        $('#bottom').show();
        check();
    });
});

$('#open'); is an <input> box. <input>框。

Instead of hiding, the lower bar stays. 下方的栏杆没有隐藏,而是停留。 The text 'loading' also appears beneath (for some reason). 文本“正在加载”也出现在下方(由于某种原因)。 This is especially strange as I can't find it in the DOM when inspecting on my computer. 这特别奇怪,因为在计算机上检查时无法在DOM中找到它。

Link: www.scriptr.net/webapp 链接: www.scriptr.net/webapp

Try listening to a different ready event for mobile. 尝试收听其他准备就绪的移动事件。 Something like this 像这样

document.addEventListener("deviceready",onReady,false);


function onReady() {
   $("#open").focus( function() {
       $('#bottom').hide();
   });

   $("#open").blur( function() {
       $('#bottom').show();
       check();
   });
}

just put this code on deviceReady function, work for me 只需将这段代码放在deviceReady函数上,为我工作

 document.addEventListener('focusout', function(e) {window.scrollTo(0, 0)});
                                        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();
                                                                  }
                                                                  }, false);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM