移动端点击input出现虚拟键盘对fixed的判断 jquery javascript原生 1. [代码] [JavaScript]代码 var clickObj=$(".dd"); var obj=$(".Submit"); clickObj.on('focus',function(){ obj.css('position','static'); }).on('blur',function(
jquery
javascript原生
1. [代码][JavaScript]代码
var clickObj=$(".dd"); var obj=$(".Submit"); clickObj.on('focus',function(){ obj.css('position','static'); }).on('blur',function(){ obj.css({'position':'fixed','bottom':'2.4rem'}); }); function focusBlur(clickID,Id){ var clickObj=document.getElementById(clickID); var obj=document.getElementById(Id); clickObj.onfocus = function(){ obj.style.position='static'; obj.style.bottom='none'; console.log(111); }; clickObj.onblur = function(){ obj.style.position='fixed' obj.style.bottom='2.4rem'; console.log(222); }; } focusBlur('dd' , 'Submit'); focusBlur('dd1' , 'Submit');