javascript - 属性 'title' 的值已更改。如何让tooltip看懂呢?

标签 javascript jquery ajax jquery-ui tooltip

当我将鼠标悬停在 .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/

相关文章:

PHP/jQuery/Javascript - 变量中仅允许数字和某些字符

javascript - react 上下文 : When Are Children Re-Rendered?

javascript - 定位Div onClick,点击外部时隐藏

javascript - 如何使用jquery ajax进程访问单独的PHP页面中的函数?

javascript - 在 URL 中传递一个包含 '%' 的参数?

javascript - 当您只知道 <tr> 时如何提取 <td> 的值

jquery - 根据背景更改图像颜色

jquery 移动事件不起作用?

javascript - 如何计算 json 对象中的属性不同值

javascript - 如何从异步调用返回响应?