下面是我的代码,同时通过onclick事件发送两个参数时,我收到一条错误消息,内容为“未捕获的SyntaxError:无效或意外的令牌”
html += "<td class='" + className + "'><a href='#' data-toggle='modal' data-target='#tourRequModal' onclick='dateSel(" + Date + "|" + priceArr[i] + ")'>" + i + priceText + "</a></td>";
答案 0 :(得分:1)
仅在此处使用日期会导致问题,因此将其写为:
html += "<td class='" + className + "'><a href='#' data-toggle='modal' data-target='#tourRequModal' onclick='dateSel(\"" + new Date().toString() + "\"," + priceArr[i] + ")'>" + i + priceText + "</a></td>";