Reputation: 70466
on my page I have a lot of items displayed. You can scroll around and view them. By clicking on an item a little tooltip appears.
I have realized that with qTip, a jQuery tooltip library. My problem is that when I scroll down and click on an item the page scrolls up again so I have to scroll down again to view the tooltip.
Any ideas how to solve that?
Upvotes: 1
Views: 1361
Reputation: 15835
<a href="#" class="test"> hello </a>
the following code will make the page jump to top because of its default behavior href=#
$(".test").click(function() {
alert("alert")
});
// event.preventDefault() will fix the default behavior of href and stops the jump to happen
$(".test").click(function() {
alert("alert")
event.preventDefault()
});
Upvotes: 2
Reputation: 4403
If you are you using a href="#"
on your items, you need to return false
in your click handler, else it will fall through to the browser's default handlers, and #
means 'go to top of the page'.
Upvotes: 3