问题
Does anybody know how to use tooltip at runtime using livequery? I found some infos, but for me it doesnt work.
jQuery('.button').bind('click', function () {
std();
});
function std () {
jQuery('.abcd').livequery.run(function() {
jQuery('.abcd').tooltip();
});
}
回答1:
I interpret your code to mean this:
When .button
is clicked you want to enable the tooltip functionality on all elements with class .abcd
. If this is your intention simply use
jQuery('.button').bind('click', function () {
std(); //activate tooltip support
});
function std () {
//internal function is called once for every found/new .abcd element
jQuery('.abcd').livequery(function() {
$(this).tooltip();
});
}
Note that probably should prevent .button
from being clicked more than once as that could lead to unexpected sideeffects
来源:https://stackoverflow.com/questions/2452645/using-jquery-tooltip-at-runtime-by-livequery