JS中通過方法名字符串調用方法

<script>
  function alertFunc(str1,str2,str3){
       alert(str1);
       alert(str2);
       alert(str3);
   }
 
 function callAlert(functionName){
       var  func=eval(functionName);

      new func(arguments[1],arguments[2],arguments[3]);

  }
 
 </script>
 
 <button onclick="callAlert('alertFunc','bb','cc','dd')" >aa</button>
 
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章