当我将鼠标悬停在 .notice
类的元素上时,工具提示会显示蓝色。当我再次将其悬停时,它会向我显示 Ajax 返回的内容。
<script>
$(".notice").tooltip();
$(".notice").mouseover(function() {
$.ajax({
type: "post",
url: "/wp-content/themes/your-click/ajax-request.php",
data: { comment_id_tooltip: $(this).attr("id") },
success: function(result) {
$(".notice").attr("title", result);
}
});
});
</script>
<td><i title="blue" id="' . $get_uncontacted_member->id . '" class="fa fa-comment-o notice comment_form"></i></td>
如何摆脱这种“蓝色”并使工具提示从头开始显示 Ajax 的内容?
最佳答案
您可以在加载时而不是在鼠标悬停时获得工具提示。
<script>
$(document).ready(function() {
$.ajax({
type: "post",
url: "/wp-content/themes/your-click/ajax-request.php",
data: { comment_id_tooltip: $('.notice').attr("id") },
success: function(result) {
$(".notice").attr("title", result);
$(".notice").tooltip();
}
});
});
</script>
<td><i title="blue" id="' . $get_uncontacted_member->id . '" class="fa fa-comment-o notice comment_form"></i></td>
关于javascript - 属性 'title' 的值已更改。如何让tooltip看懂呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30656642/