js奇葩错误 字符串传递问题

第一种方式
function hello(){
    var name="he";
    var content="<input type=button value='TEST' onclick='helll(""+name+"")'  />";
    $("#hello").html(content);
}
function helll(name){
    alert(name);
    this.func=new Function(name+"();");
    func();
}
function he(){
alert("hell");
}
第二种方式
function hello(){
    var name="he";
    var content="<input type=button value='TEST' onclick='helll(""+name+"")'  />";
    $("#hello").html(content);
}
function helll(name){
    alert(name);
    func=function(data){};
    this.func = eval(name);
    func("hel");
}
function he(name){
alert("hell"+name);
}
</script>

原文地址:https://www.cnblogs.com/a757956132/p/4065471.html