javascript - dynamic variables

前端 未结 2 536
甜味超标
甜味超标 2020-12-02 03:02

Hi I am trying to make dynamic variables but it is saying `variable v0 (through to v5) is not defined.

td.each(function(i){
eval(\'var v\' + i + \' = \\\'\'          


        
2条回答
  •  生来不讨喜
    2020-12-02 03:24

    That sounds like a bad idea.

    Is there any reason you can't do this?

    var tdHtml = td.map(function() { return $(this).html(); }).get();
    

提交回复
热议问题