JS函数传递两个参数,要用引号把参数引起来
1 <input type="button" οnclick=" method(‘param1‘,‘param2‘)"> 2 3 <script> 4 function method(param1,param2){ 5 alert(param1); 6 location.href="param2"; 7 } 8 </script>
js中动态传递参数还需要使用转义字符
<script type="text/javascript">
var param1="";
var param2="";
document.getElementById("test").innerHTML(" <button οnclick=‘ testmethod( \‘ ‘+param1+‘ \‘ , \‘ ‘+param2+‘ \‘ ) ‘></button>");
</script>
原文链接:https://blog.csdn.net/amnb123/article/details/50718552