本文介绍了刷新元素,以便显示其新工具提示(在jQuery/Javascript中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个html元素,将其悬停时使用引导工具提示显示标题.但是,当您单击此元素时,我正在更改工具提示,但是直到我将鼠标从其上移开并再次悬停在该元素上时,新的工具提示才会显示.

I have an html element which is using bootstrap tooltip to show a title when hovering over it. However, when you click this element I'm changing the tooltip, but the new tooltip isn't showing until I remove the mouse from it and re-hover over the element again.

我希望单击该按钮时立即显示工具提示.我怎样才能做到这一点?缺少更好的词,是否有办法刷新"一个html元素?

I want the tooltip to be shown instantly when said button is clicked. How can I achieve this? Is there a way to "refresh", in lack of better words, an html element?

推荐答案

尝试这种方式

HTML代码:

 <h3>
Sensors Permissions
   <i class="icon-info-sign" data-toggle="tooltip" title="first tooltip" id='example'></i>
 </h3>

JQUERY代码:

$(document).ready(function () {
   $('#example').tooltip();
   $('#example').on('click', function () {
     $(this).attr('data-original-title', 'changed tooltip');
     $('#example').tooltip();
     $(this).mouseover();
   });
});

实时演示:

http://jsfiddle.net/dreamweiver/9z404crn/

注意:以上逻辑仅适用于Bootstrap版本 2.3.2 及以下版本,但是@ NabiK.AZ提供的解决方案也适用于最新版本.

Note: Above logic works only with Bootstrap version 2.3.2 and below, however the solution provided by @NabiK.A.Z's would work with latest version as well.

快乐编码:)

这篇关于刷新元素,以便显示其新工具提示(在jQuery/Javascript中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 18:59