这是我需要调用的函数
function printExpectationReport(Interest, Influence) {}
A 和 B 是两个字符串变量,当我单击它时,控制台给出错误,因为 A 和 B 未定义。
如果有人知道我应该如何绑定字符串的变量。这将非常有帮助。
TableData += "<div class='count-expectation'><a onclick='printExpectationReport("+A+","+B+") href='#'>" + arrayFound.length + "</div>";
这样做
var a = 'something';
var b = 'something else';
$(document).on('click', 'a', function (e) {
e.preventDefault();
printExpectationReport(a, b);
});
还要记住,动态添加到文档中的元素上的绑定事件应使用我上面提供的语法on()
完成。