textbox 获得焦点提示

有时候我们在注册的时候希望在文本框获得焦点时给予提示,这是我在网上找的,再根据自己需要整理
<script type="text/javascript">
    function showDIV(divID,obj)
        {
            var myDiv=window.document.getElementById(divID);
            var txt=obj;
            var txtTop=txt.offsetTop;
            var txtLeft=txt.offsetLeft;
            if(txt.offsetParent!=null)
            {////递归获得元素的位置
                txtTop+=getTop(obj);
                txtLeft+=getLeft(obj);
            }
            myDiv.style.top=txtTop;
            myDiv.style.left=txtLeft+125;
            myDiv.style.display='block';
           
        }
        function hidDIV(divID)
        {
            var myDiv=window.document.getElementById(divID);
            myDiv.style.display='none';
        }
        function getTop(e){
        var offset=e.offsetTop;
        if(e.offsetParent!=null)
        offset+=getTop(e.offsetParent);
        return offset;
        }
        function getLeft(e){
        var offset=e.offsetLeft;
        if(e.offsetParent!=null) offset+=getLeft(e.offsetParent);
        return offset;
        }

   
    </script>

Top
收藏
关注
评论
原文地址:https://www.cnblogs.com/judypol/p/1552262.html