var dayNumberCell = doc.createElement('td');
dayNumberCell.className = 'days_link';
dayNumberCell.setAttribute('onclick', function(scope) {
var bindScope = function() {
scope.changeDate(this, this.id);
scope.returnDate(scope.month, scope.year);
};
return bindScope;
}(this));
上面的代码生成 tds onclick 事件监听器。生成的代码看起来像
<td class="days_link" onclick="function () {
scope.changeDate(this, this.id);
scope.returnDate(scope.month, scope.year);
}">15</td>
通过单击 TD,我收到语法错误消息。我应该如何编写指定代码执行并且没有语法错误的函数。
提前致谢。