onclick函数动态传参
1.参数为数值类型时:
var tmp = 123;var strHTML = "点击弹出数据及其类型";info.append(strHTML);function func(tmp) { alert(typeof tmp + " " + tmp);}
string 123
2.参数为字符串类型时:
var tmp = "abc";var strHTML = "点击弹出数据及其类型";info.append(strHTML);function func(tmp) { alert(typeof tmp + " " + tmp);}
打印出 string abc
3.传两个及以上的参数时:var tmp = "abcda";var type = "xza";//tmp参数和type参数之间不能有空格var strHTML = "点击弹出数据及其类型";info.append(strHTML);function func(tmp, type) { alert(tmp + " " + type);}
打印出 abcda xza
4.参数为数组时:
var tmp = ["abc", "ddd", "gg"];var strHTML = "点击弹出数据及其类型";info.append(strHTML);function func(tmp) { alert(typeof tmp + " " + tmp);}
打印出 string abc,ddd,gg