zoukankan      html  css  js  c++  java
  • HTML 文本框获取焦点提示输入文字消失,失去焦点显示

    function TextInfo(element, info) { 
        this._textBox = element;
        this.text = info;
        this._textBox.value = info;
        this._textBox.onblur = new createDelegate(this, this._onblur);
        this._textBox.onfocus = new createDelegate(this, this._onfocus); 
    }
    TextInfo.prototype = {
        _onblur: function () {
            if (this._textBox.value.length == 0) {
                this._textBox.value = this.text;
            }
        },
        _onfocus: function () { 
            if (this._textBox.value.length != 0 && this._textBox.value == this.text) {
                this._textBox.value = "";
            }
        }
    } 
    //方法委托,确保this关键字作用域正确。 createDelegate
    = function(instance, method) { return function () {
         //指定方法调用者 
    return method.apply(instance, arguments); } }

    调用:new TextInfo(document.getElementById("textMarks"), "请输入用户名");

  • 相关阅读:
    fpga不错的源代码下载地址
    iverilog命令选项解释
    altera官方视频教程下载地址
    niosII EDS和QuartusII安装心得体会
    FPGA的JTAG口很脆弱?
    poj2379
    poj2472
    poj2935
    poj3366
    poj1493
  • 原文地址:https://www.cnblogs.com/you000/p/2830059.html
Copyright © 2011-2022 走看看