【发布时间】:2020-09-19 11:27:06
【问题描述】:
我正在尝试将 JSON 对象传递给 onclick 函数,但它不起作用
$.each(response, function(k, v) {
html += "<tr>";
html += " <td><a onclick='showcomplaints('+ v.ID +')' >" + v.ID + "</a></td>";
html += " <td>" + v.Name + "</td>";
html += ' </tr>';
});
function showcomplaints(id)
{
alert(id);
}
我在控制台窗口中收到此错误“Uncaught SyntaxError: Unexpected end of input”。
【问题讨论】:
-
只需像在文本值中那样连接参数中的
v.ID
标签: javascript php jquery jquery-ui