Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make qTip2 for jQuery work only on click?

Tags:

jquery

qtip2

I am using the qTip jQuery plugin, and want the tooltip to appear only when clicking a link or button. I have found several methods that are supposed to work, but don't seem to work in practice. Here is a jsFiddle where I tried two different methods: http://jsfiddle.net/dqkzV/2/. There is also another answer on here which claims to work, but doesn't seem to work for me (2nd method on my jsFiddle): jQuery tooltip onClick?. With both methods I tried, the tooltip still appears on mouseover, when it is only supposed to appear on click.

like image 965
Dustin Avatar asked Dec 28 '22 09:12

Dustin


1 Answers

Your first method is just adding a qTip to the <body> when the .clickme button is clicked, although I do not understand why it seems to not be added and then sometimes appears on mouseover.

The second method is using the show syntax from qTip 1.0 but you have included qtip 2 as the library in the fiddle. The qTip 2 show API is very different.

The following should show the tooltip when the button is clicked.

JavaScript (jQuery)

$('.clickme').qtip({
    content: 'Hello 2nd Test',
    show: 'click'
});
like image 123
andyb Avatar answered Dec 29 '22 22:12

andyb