Matt Hutch Matt Hutch - 2 months ago 6
jQuery Question

.delay() not working on my .show() JQuery

I'm trying to make my footer disappear when on a mobile device and only when the keyboard is open. Which I have working perfectly, however the issue is that the footer reappears before the keyboard has time to close. Which is because I'm using the event from the textbox having focus not the keyboard being open. So I thought the best way to resolve this is with a

.delay()
however, this isn't working at all. Anyone have any ideas here?

<script>
var isMobileView = false; //global variable

$(document).ready(function () {

function setScreenWidthFlag() {
var newWindowWidth = $(window).width();
if ( $(window).width() > 600) {
isMobileView = false;
}
else {
isMobileView = true;
}
}

$(".tbinputArea").focus(function() {
if(isMobileView)
$("#footer").hide();
});

$(".tbinputArea").focusout(function() {
if(isMobileView)
$("#footer").delay(500).show();
});

setScreenWidthFlag();

$(window).on("resize", function (e) {
setScreenWidthFlag();
});
});
</script>

Answer
$("#footer").delay(500).show(0);

Try this.

Comments