js里面拼接带:的字符串(冒号),如果这样拼接,会报js错误:缺少')',用火狐浏览器调试,发现此处拼接成了这样:javascript:pause(,后面的内容全部丢失了。
var id="process:10:115010";hm = "<a href='javascript:stateSet(" + id + "," + state + ")'>停止</a>"
试了很多方法之后,发现以下两种写法可以解决以上问题
方法一:
var id="process:10:115010";hm = "<a href='javascript:stateSet("" + id + ""," + state + ")'>停止</a>"
方法二:
hm = "<a href='javascript:stateSet(\""+ id + "\"," + state + ")'>停止</a>"