Keep Twitter Bootstrap Tooltip open on mouseleave

故事扮演 提交于 2019-12-03 11:38:14

问题


For a particular case and element I need to show Bootstrap Tooltip by default (once the page is loaded) an always keep it open (even on mouseover and mouseout).

That's the code I use to open tooltip by default on the element:

$('#myelement').tooltip('show');

Now I'm not sure how to prevent/disable the default action of tooltip on mouseover & mouseout. Any idea?

Thanks in advance!


回答1:


Solution found. Manual Trigger does the trick - here is the updated code:

$('.taskTooltip').tooltip({trigger: 'manual'}).tooltip('show');



回答2:


Use unbind() after show : it will remove all event handler and thus the tooltip won't hide on mouseleave

$(".circle").tooltip("show");
$(".circle").unbind();
.circle{
margin-left:100px;
margin-top:80px;
width:10px;
height:10px;
background-color:#0088ff;
border-radius:50%;
border:1px solid #ff8800;

}
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<div class="circle" data-toggle="tooltip" data-placement="top" title="Hello World !"></div>


来源:https://stackoverflow.com/questions/15627619/keep-twitter-bootstrap-tooltip-open-on-mouseleave

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!