0

オブジェクトの属性を動的に設定しようとしています。以下の例を見てください。

function testFunc(type, scope){
    this.scope = scope;
    this.scope.setAttribute(type, true);
    this.doSome = function(){return //Something;}
}

setAttributeしかし、メソッドは DOM 要素に対してのみ使用できることに気付きました。属性を js オブジェクトに動的に設定する方法はありますか?

4

1 に答える 1

2
function testFunc(type, scope){
    this.scope = scope;
    this.scope[type]= true;
    this.doSome = function(){return //Something;}
}

トリックを行う必要があります。

于 2013-03-16T08:28:55.850 に答える