我有以下内容:
<select id="price_select"></select>
我有一个调用以下内容的事件处理程序:
var selected_option = "one";
var option_one = "<option>Option Contents</option>";
document.getElementById('price_select').innerHTML = eval('option_' + selected_option);
在 Firefox 中工作正常,但在 IE6 中不行。
最佳答案
你就不能做这样的事情吗?
var selected_option = "one";
var options = { "one": "<option>Option Contents</option>" };
document.getElementById('price_select').innerHTML = options[selected_option];
关于javascript - 如何让 eval 在 IE 中正常运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/924135/