How to detect keyboard show/ hide event in jquery for mobile web application

后端 未结 5 1920
故里飘歌
故里飘歌 2020-12-30 01:00

I am working on web base mobile (HTML) application. Is there any way to detect keyboard event like when keyboard is visible and keyboard hide, base on that I can control o

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-30 01:07

    Hi here is one of the solution which worked for me to check if keyboard is active in mobile devices.

    In the below code "#Email" is the id of the input field I am using.

       $(window).resize(function () { //checking for window resize event
    
        if($(window).width() < 414){ //checking for window width
             if($("#Email").is(":focus")){
                 $('.content').css({'margin-top': -15 + 'px'});
                 $('.footer').css({'margin-bottom': -100 + 'px'});
             }
        }});
    

提交回复
热议问题