开发者

Set element style/property in for loop

I'm trying to set prop开发者_Python百科erties of some elements through a for loop, but am confused about the implementation.

Here is the code:

var fiArray = new Array('name','address','address2','phone','fax','misc1','misc2');

function disableFields(){
   for(i=0,x=fiArray.length; i < x; i++){
       var disEl = "$('formID')."+fiArray[i];
       disEl.disabled=true;
   }

}

I've tried every permutation of changing the disEl var, not using a var, concatenating different parts of the disEl string; nothing seems to work.

I know I'm missing something simple and fundamental here...

p.s. using prototype


var disEl = $('formID')[fiArray[i]];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜