我试图让一个div在文本框聚焦时出现,在文本框失去焦点时消失。这应该发生在人像模式下的iPad上(因此检查w
/*if the search-bar looses focus*/
$("#activate-search").focusout(function(ev){
if (w < h) {
$(".left-pane").hide();
$("#senior-card-container").css("margin-top", "40px");
ev.stopPropagation();
};
});
/*if the search-bar gets focus*/
$("#activate-search").focusin(function(){
if (w < h) {
$(".left-pane").show();
$("#senior-card-container").css("margin-top", "250px");
$(".navbar").css("position", "fixed", "top", "20px");
};
});
看看这里的
不幸的是,这是不可能的。我对jQuery和portables也有问题。
也许可以帮助解决模糊问题。
<input type="text" id="search" />
<input type="text" id="search2" />
var isIpad = /(iPad).*AppleWebKit(?!.*Safari)/i.test(navigator.userAgent);
if (isIpad === true) {
$("#search").on('click', function () {
lastFocus = $(this).attr('id');
checkFocusInterval = setInterval(blurIpad, 200);
});
}
function blurIpad() {
var focusNow = document.activeElement;
if (focusNow.getAttribute('id') != lastFocus) {
clearInterval(checkFocusInterval);
alert('The iPad has left the hou.. uhhm input')
}
}