首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

请问一个字符串转函数方法

2013-08-04 
请教一个字符串转函数方法。function cls(){this.A function(s){var x s + MX//问题在这里this.x()

请教一个字符串转函数方法。


function cls(){
this.A = function(s){
var x = s + 'MX';
//问题在这里
this.x();
//我想得出i am here的结果,这里的"x"这个字符串应该如何进行转化?
}

this.techMx = function(){
alert('i am here');
}
}

var j = new cls();
j.A('tech');

[解决办法]
    function cls() {
        this.A = function (s) {
            var x = s + 'Mx';//注意大小写
            this[x]();///////////
        }

        this.techMx = function () {
            alert('i am here');
        }
    }

    var j = new cls();
    j.A('tech');

热点排行
Bad Request.