Ajax 动态元素上的jquery工具提示
我使用这个插件将元素上的工具提示设置为Ajax 动态元素上的jquery工具提示,ajax,dynamic,tooltip,Ajax,Dynamic,Tooltip,我使用这个插件将元素上的工具提示设置为 $('.showtooltip').tooltip({ delay: 0, track: true, showURL: false, bodyHandler: function() { var tipStr = "SOME DISPLAY HTML"; return $(tipS
$('.showtooltip').tooltip({
delay: 0,
track: true,
showURL: false,
bodyHandler: function() {
var tipStr = "SOME DISPLAY HTML";
return $(tipStr);
}
});
我的ajax动态创建元素
$("<img alt='' class='showtooltip' src='image.jpg' />");
但工具提示仅在首次将鼠标悬停在图像上后显示。
如何在dynamic元素上使用工具提示?在ajax调用后,我使用类似这样的方法重新绑定。这可能会有帮助
$(".showtooltip").live("mouseover",function(){
if (!$(this).hasClass("tooledUp")){
$(this).tooltip({
delay: 0,
track: true,
showURL: false,
bodyHandler: function() {
var tipStr = "SOME DISPLAY HTML";
return $(tipStr);
}
});
$(this).tooltip().show();
$(this).addClass("tooledUp");
}
});
从这里的论坛:
$(文档).ready(函数(){
$(“#btn”)。单击(函数(){
$(“”).appendTo($(this.parent()).ready(function()){
$(此)。工具提示({
延迟:0,
轨迹:对,
showURL:false,
bodyHandler:function(){
var tipStr=“一些显示HTML”;
返回$(告密者);
}
}).addClass(“tooledUp”).show();
});
});
});
$(".showtooltip").live("mouseover",function(){
if (!$(this).hasClass("tooledUp")){
$(this).tooltip({
delay: 0,
track: true,
showURL: false,
bodyHandler: function() {
var tipStr = "SOME DISPLAY HTML";
return $(tipStr);
}
});
$(this).tooltip().show();
$(this).addClass("tooledUp");
}
});
<input type="button" id="btn" value ="Click here" />
$(document).ready(function(){
$("#btn").click(function(){
$("<input type='checkbox' title='waaaaw' />").appendTo($(this).parent()).ready(function(){
$(this).tooltip({
delay: 0,
track: true,
showURL: false,
bodyHandler: function() {
var tipStr = "SOME DISPLAY HTML";
return $(tipStr);
}
}).addClass("tooledUp").show();
});
});
});