示例:
var device_mac="11qweq234ert";
//第一種方式會報錯:Onclick SyntaxError: identifier starts immediately after numeric literal,數字后面緊跟着字符
這種寫法只有device_mac是數字的時候是正確的。傳入的為字符串則應該使用第二種方法。
1,return "<INPUT type='button' value='分析' onclick='showCollectInfo("+device_mac+")'>";
2,return "<INPUT type='button' value='分析' onclick='showCollectInfo(\""+device_mac+"\")'>";
注意點:需要用轉義字符