移入页面上空文本框时,让它变为焦点,移出清除焦点
来源:广州中睿信息技术有限公司官网
发布时间:2012/10/21 23:25:16 编辑:admin 阅读 518
varPage_INIT=function(){$(document).bind("mouseover",function(e){//鼠标移入if(e.target.tagName.
var Page_INIT = function () {
    $(document).bind("mouseover", function (e) {//鼠标移入
        if (e.target.tagName.toUpperCase() == "INPUT") {
            var input = e.target;
            if (input.type == "text") {//如果是文本框
                if (window.Page_FocusTimer) {//如果处于焦点状态
                    window.clearTimeout(window.Page_FocusTimer);//清除焦点状态
                }

window.Page_FocusTimer = window.setTimeout(function () {

//每0.2豪秒去执行这个匿名方法一次

                    if (!input.value) {//如果内容为空,则设为焦点
                        try {
                            input.focus();
                        } catch (e) { }
                    }
                }, 200);
            }
        }
    }).bind("mouseout", function (e) {//鼠标移出

if (e.target.tagName.toUpperCase() == "INPUT") {

//被处理的事件源对象它的名称(即HTML标记)转为大写后如果是INPUT

            var input = e.target;
            if (input.type == "text") {
                if (window.Page_FocusTimer) {
                    window.clearTimeout(window.Page_FocusTimer);
                }
            }
        }
    });
}
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }
联系我们CONTACT 扫一扫
愿景:成为最专业的软件研发服务领航者
中睿信息技术有限公司 广州•深圳 Tel:020-38931912 务实 Pragmatic
广州:广州市天河区翰景路1号金星大厦18层中睿信息 Fax:020-38931912 专业 Professional
深圳:深圳市福田区车公庙有色金属大厦509~510 Tel:0755-25855012 诚信 Integrity
所有权声明:PMI, PMP, Project Management Professional, PMI-ACP, PMI-PBA和PMBOK是项目管理协会(Project Management Institute, Inc.)的注册标志。
版权所有:广州中睿信息技术有限公司 粤ICP备13082838号-2