js函数传递两个参数

来源:互联网 发布:积分兑换系统源码 编辑:程序博客网 时间:2024/06/01 08:53
function testmethod(param1,param2){
    alert(param1);alert(param2);
}
<button onclick="testmethod('param1','param2')"></button>
要用引号把参数引起来
js中动态传递参数还需要使用转义字符
<script type="text/javascript">
var param1="";
var param2="";
document.getElementById("test").innerHTML("<button onclick='testmethod(\''+param1+'\',\''+param2+'\')'></button>");
</script>
0 0