编写一个javascript方法来使用线程概念更新文本框(或)任何其他控件值

时间:2016-11-24 10:32:16

标签: javascript

我没有得到这方面的确切解决方案......请帮助大家......提前致谢。

    function Variable(initVal, onChange) {
        debugger;
        this.val = initVal;          //Value to be stored in this object
        this.onChange = onChange;    //OnChange handler

        //This method returns stored value
        this.GetValue = function () {
            return this.val;
        }

        //This method changes the value and calls the given handler
        this.SetValue = function (value) {
            this.val = value;
            this.onChange();
        }
    }
    var myVar = new Variable(10, function () { alert("Value changed!"); });

    alert(myVar.GetValue());

    myVar.SetValue(12);

    alert(myVar.GetValue());

0 个答案:

没有答案