最近我开发了一个函数,我需要通过ajax为动态生成的HTML添加一个函数。代码如下所示:如何在ajax中返回动态html中绑定函数
$.ajax(
'success': function(data){
//do sth
a.html(res);
$(document).on('hover',sth in res,function(){
console.log(1)
$(this).toggleClass('classA').toggleClass('classB');
})
}
)
它似乎并没有因为console.log()
工作不打印任何东西。绑定过程中是否存在问题?我改变了悬停点击,鼠标等,并没有一个似乎工作。 ajax调用中的其他函数正常工作。
什么是'在水库'? – aldrin27
看起来像OP插入垃圾投入,同时认为焦点在其他地方:) –
在res resh中是一个类名称在res字符串中,就像'.classA' –