我有这张桌子......
+-----+--------+------+-----+-----+
|categ| nAME | quan |IDUNQ| ID|
+-----+--------+------+-----+-----+
| 1 | Z | 3 | 1 | 15 |
| 1 | A | 3 | 2 | 16 |
| 1 | B | 3 | 3 | 17 |
| 2 | Z | 2 | 4 | 15 |
| 2 | A | 2 | 5 | 16 |
| 3 | Z | 1 | 6 | 15 |
| 3 | B | …Run Code Online (Sandbox Code Playgroud) 我听说在JavaScript中使用eval函数是个坏主意,但我有这个代码:
// this string (function) is generated dynamically...
var funVal = 'alert("a")' ;
//.....
var Button1 = document.getElementById("BtnSave");
// onclick event of button
eval("Button1.onclick = function () { " + funVal + " };");
Run Code Online (Sandbox Code Playgroud)
我不想用eval.还有其他解决方案吗?