示例:

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+"\")'>";

 

注意点:需要用转义字符

相关文章:

  • 2022-02-12
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2022-02-17
  • 2021-12-06
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
  • 2021-10-16
  • 2021-12-18
  • 2022-12-23
相关资源
相似解决方案