我对绑定到事件的jquery.on()
函数有点熟悉,类似于:
$(document).on("mouseover", ".myclass", function() {
$(this).customerFunction(); //or something like .tooltip()
return this;
});
但是,如果HTML中存在customerFunction()
,而不是仅仅在事件发生时,如何将此.myclass
绑定到?我知道我能做到
$(".myclass").customerFunction();
用于标准页面加载,但如果页面是通过ajax加载的,则不起作用。
干杯,
答案 0 :(得分:1)
尝试以下
$("[rel='tooltip']").on("mouseover", function() {
$(this).tooltip();
return this;
});
答案 1 :(得分:0)
看起来像是jQuery选择器中常见的错误
您需要引用'tooltip'
尝试"[rel='tooltip']"
答案 2 :(得分:0)
Neverever给了我一个好主意。我试过了,它有效!
$(document).ajaxSuccess(function() {
$('.myclass').customerFunction(); //or $("[rel=tooltip]").tooltip();
return this;
});