Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
165 views
in Technique[技术] by (71.8m points)

javascript - How to make bootstrap tooltip remain visible till the link is clicked

I have a link which I am going to use as notification when a user has some new notification I am going to notify the user by showing a tooltip(twitter bootstrap tooltip). What I want to achieve is, that tooltip should remain visible till the user clicks the link. once the user clicks the link, the tooltip should destroy. this is what I have till now, http://jsfiddle.net/testtracker/QsYPv/

HTML

<p><a href="#" rel="tooltip" data-original-title="you have 2 notifications">Notification</a>.</p>?

JavaScript

$('p a').tooltip({placement: 'bottom'}).tooltip('show');?

What's happening there is, tooltip stays visible till you hover it, and takes its default behaviour (show on hover) once you hover it.

I hope I have given proper info and cleared what I want to do.

question from:https://stackoverflow.com/questions/13015432/how-to-make-bootstrap-tooltip-remain-visible-till-the-link-is-clicked

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Here is the solution http://jsfiddle.net/testtracker/QsYPv/8/

Added the option "trigger"

$('p a').tooltip({placement: 'bottom',trigger: 'manual'}).tooltip('show');

then, with this line

$('p a').on('click',function(){$(this).tooltip('destroy');});

destroy tooltip on click.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...