javascript - 动态变量 [英] javascript - dynamic variables

查看:127
本文介绍了javascript - 动态变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力制作动态变量,但是它说变量v0(至v5)没有定义。

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 + ' = \'' + $(this).html() + '\';' );
});

任何帮助将非常感谢。

any help would be muchly appreciated.

推荐答案

这听起来像个坏主意。

有没有原因你不能这样做?

Is there any reason you can't do this?

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

这篇关于javascript - 动态变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆