首页 > Web开发 > 详细

解决jQuery中input 失去焦点之后,不能再获取到焦点

时间:2020-01-17 14:04:46      阅读:105      评论:0      收藏:0      [点我收藏+]
//编辑过敏史
        if(iToolbar == ‘editGMS‘){
            lstype="gms";
            var gms="";
            if(gmstype=="0"){
                gms=$(‘#GMSInfo‘).html();
                $(‘#GMSDIV‘).html(‘<textarea class="form-control" id="GMSDesc" name="GMSDesc" style="width:100%; height:80px;" maxlength="500" autofocus="autofocus">‘+gms+‘</textarea>‘);
                gmstype="1";
                window.setTimeout (function(){ document.getElementById (‘GMSDesc‘). select();},0 );//自动获取焦点
            }
            
             $("#GMSDesc").on("blur",function(){//失去焦点事件
                 if(gmstype=="1"){
                        gms=$(‘#GMSDesc‘).val();
                    }else{
                        gms=$(‘#GMSInfo‘).html();
                    }
                    setTimeout(function(){//延迟执行
                         $.ajax({
                                type : "POST",
                                url : ‘<%=request.getContextPath()%>/Svl_ConsultationManage‘,
                                data : ‘active=editJBS&iUSERCODE=‘+pid+‘&jbinfo=‘+gms+‘&lstype=‘+lstype,
                                dataType:"json",
                                success : function(data){
                                    gmstype="0";
                                    $(‘#GMSDIV‘).html(‘<span id="GMSInfo" name="GMSInfo">‘+gms+‘</span>‘);
                                }
                            });
                        },150);
                    })  
        }
        

此方法ie、火狐均兼容效果图如下:

技术分享图片

解决jQuery中input 失去焦点之后,不能再获取到焦点

原文:https://www.cnblogs.com/bgyb/p/12204807.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!