Question

I've created a link with a qtip2 tooltip using the following code:

<a href="#" class="mylink">Show Tooltip</a>

$('.mylink').qtip({
  show: {event: 'click'}
});

When the link is clicked, the tooltip opens as expected, but the browser also navigates to /#, which causes the screen to scroll to the top. How can I prevent the original click event, without interfering with qtip?

Was it helpful?

Solution

Found the answer here. Just bind to the click event of the link and use preventDefault.

$('.mylink').qtip({
  show: {event: 'click'}
}).bind('click', function(event){ event.preventDefault(); return false; });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top